The first thing you need to do is open up the Automator application which is installed by default on OSX:
Next you need to click on Library and find the "Run AppleScript" workflow:
This will let you configure a new AppleScript where you can put the commands or shell script to run. Note that if your script needs to be run under sudo, you need to use the "with administrator privileges" clause:
Now just save the file (this will be saved as an application) - You can drag this application to your dock which you can execute at any time.