A patch coming about earlier this year allows setting the system’s hostname before user-space starts by way of the hostname= kernel parameter. That patch has now landed as part of Andrew Morton’s accumulated changes for Linux 6.0…
Source: Phoronix – Linux 6.0 Allows Setting The Hostname Via New “hostname=” Parameter