This is a os-agnostic question; When deploying to a large number of machines, the only thing you have to differentiate them with is a mac address; DHCP can assign an IP to each machine based on it's mac address, and then DNS will assign it a FQDN but if you deploy the same image to many machines over a network, the OS on the image itself has to know how to set the hostname of the machine when it boots up; so how does the booted / written os image determine how to set its own hostname?
dhcp protocol can send hostname. It can be set with
request host-name option in gnu/linux.
As you already said: it either does a reverse lookup of the ip-address that gets assigned by DHCP and sets the hostname from there or it sets the hostname that gets sent as DHCP option 12