Change the Hostname in Mac OS X via Terminal Permanently
To change the hostname and have it set persistent after reboots, you will want to use the scutil command rather than the hostname command. This is done through the Terminal, and you will need to enter an administrator password for changes to take effect, and you can either run the command prefixed with 'sudo' or as is, which will summon an admin request on it's own.
An accompanying article can be found here:
http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/
This works to permanently set a hostname in OS X Mountain Lion, OS X Lion, Snow Leopard, and prior versions of Mac OS X.
A temporary change to hostname can be achieved with just the hostname command, as shown in this video: http://www.youtube.com/watch?v=kod0twaqGxg&feature=youtu.be
http://osxdaily.com