macOS: Wrong Bonjour name stuck in hostname
The man page for hostname says:


  To keep the hostname between reboots, run `scutil --set HostName name-of-host'.


Also, the name in the Sharing prefs pane you mentioned, is that the name that isvisible right there when you open the pane, or the one you can edit when you click the "Edit..." (or similar - in German it's "Bearbeiten...") button?