Change ssh connection info for Remote Login
Your command should work:

sudo scutil --set HostName YourHostName


Since OSX 10.9 Maverick, it's possible to change it with hostname command. Without -s it will be a temporary change, adding the -s will set it up permanently:

sudo hostname -s YourHostName


To verify it, you may type hostname and observe the return. 

Update

OSX uses different variables to name the machine. You may need to reset them as well.

scutil --set HostName YourHostName
scutil --set ComputerName $(hostname -s)
scutil --set LocalHostName $(hostname -s)
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $(hostname -s)