sudo scutil --set HostName [new hostname]
Example: sudo scutil --set HostName LDNMAC-1234
--set pref [newval]
Updates the specified preference with the new value. If the new value is not specified on the command line then it will be read from standard input.
Supported preferences include: ComputerName LocalHostName HostName The --set option requires super-user access. --dns Reports the current DNS configuration.