Standard command like hostname will still work in macOS, but perhaps it's best to use the native way of updating system information on your Mac? scutil command is here to help.
Change Hostname with scutil
Simply run this command in your Terminal window:
greys@macbook:/ $ sudo scutil --set HostName "maverick"
if you now start new Terminal window or even just start new shell, you should see the new hostname:
greys@macbook:/ $ sudo scutil –set HostName "maverick"
greys@macbook:/ $ bash
greys@maverick:/ $ hostname
That's it for today!