I have two buttons in toolbar, one of them locks transforms, the other one unlocks them. If you want toggle, then you need to modify the script. Sorry, but i can't help you with this.
By the way, i don't see how toggle would be better than two separate commands for this action, unless you want to assign the script to keyboard shortcut and don't want to memorize too many shortcuts.