If you are relying on Azure provided DNS, you can simply set the hostname on the machine. Azure DNS automatically takes the VM hostname and sets matching A records in DNS resolvable within the same virtual network. This means, yes you can change the name of a VM in a scaleset and it will be resolvable from other computers in that vnet. This doesn't require a reboot but may take a couple minutes to reflect.
You can read more here: https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances#azure-provided-name-resolution
The command is as simple as this:
hostnamectl set-hostname foo
You can do this from within the startup scripts provided to the scaleset, and the hosts will automatically change names after they boot up for the first time. You would need some logic in the script to figure out what to change the name to, though.