I want to change clock from 12h to 24h mode via terminal
This is stored in the plist located at ~/Library/Preferences/com.apple.menuextra.clock under the key DateFormat.
Here's a quick primer:

12 Hour Mode with AM/PM:
EEE MMM d  h:mm:ss a

12 Hour Mode without AM/PM:
EEE MMM d  h:mm:ss

24 Hour Mode:
EEE MMM d  H:mm:ss


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.
For the changes to take immediate effect, kill -SIGHUP SystemUIServer will do the trick. Otherwise they will take effect the next time you log out and back in or restart.

1 CyberCiti Primer on Shell Scripting via Applescript