You could also run the following PowerShell command to get the Hyper-V hostname inside the VM:

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters" | Select-Object HostName