I needed to change the name of one of my Macs remotely and this is the command to do it:

sudo scutil --set HostName [NewHostNameHere]