This is stored in the plist located at
~/Library/Preferences/com.apple.menuextra.clock under the key
Here's a quick primer:
12 Hour Mode with AM/PM
12 Hour Mode without AM/PM
24 Hour Mode
To apply any of these formatting strings, you can either use the
defaults command at the Terminal, or if you're looking for a more programmable method, you can use the
do shell script1 directive within Applescript.
To apply these via the Terminal, open it up and run the following command:
defaults write com.apple.menuextra.clock DateFormat -string 'EEE MMM d H:mm:ss'
Substitute the string between the quotes with the version from above that you want.
The changes don't take effect immediately after running the command, I know you can logout/log back in for the change to be made, but I'm not aware of how to apply it immediately.
1 CyberCiti Primer on Shell Scripting via Applescript