I'm not sure how the name was changed and if it's at all possible to trace it back, but you can easily change the HostName to any name using the scutil command:
sudo scutil --set HostName your_new_name
Here's a shell script I use to change various computer names (ComputerName, HostName, LocalHostName) in one step:
#!/bin/bash
# Change your computer names
# Run with sudo
# variables
id=$1
computerName=$(scutil --get ComputerName)
hostName=$(scutil --get HostName)
localHostName=$(scutil --get LocalHostName)
changeName(){
scutil --set ComputerName $id
scutil --set HostName $id
scutil --set LocalHostName $id
}
printChanges(){
clear
printf "**************OLD SETTINGS*************\n"
printf "ComputerName: $computerName\n"
printf "HostName: $hostName\n"
printf "LocalHostName: $localHostName\n\n"
newComputerName=$(scutil --get ComputerName)
newHostName=$(scutil --get HostName)
newLocalHostName=$(scutil --get LocalHostName)
printf "***********CURRENT SETTINGS************\n"
printf "ComputerName: $newComputerName\n"
printf "HostName: $newHostName\n"
printf "LocalHostName: $newLocalHostName\n\n"
}
# main
if (($#==0))
then
# print current names
clear
printf "***********CURRENT SETTINGS************\n"
printf "ComputerName: $computerName\n"
printf "HostName: $hostName\n"
printf "LocalHostName $localHostName\n\n"
elif (($#==1))
then
# change name and print changes
changeName $id
printChanges
else
echo "Expected: Empty OR NewComputerName"
fi