Set or Change Hostname (via the GUI)

Note:  If the Edit button is greyed out, click on the Lock Icon, authenticate with an admin account

Set or Change Hostname (via Terminal) - OS X Mavericks or newer