Ventura docs for M2 Macs in this comment: https://gist.github.com/henrik242/65d26a7deca30bdb9828e183809690bd?permalink_comment_id=4555340#gistcomment-4555340
Old Monterey docs in this old revision: https://gist.github.com/henrik242/65d26a7deca30bdb9828e183809690bd/32c410e3a1de73539c76fa13ea5486569c4e0c5d
Solution for Sonoma: https://gist.github.com/sghiassy/a3927405cf4ffe81242f4ecb01c382ac
Actually I got a moment free. This is on a ubiquiti device but it's probably similar to other router products.
I still create the hosts file during the process because I switch to my regular wi-fi network after everything is installed.
Waiver: I did this on a laptop that my manager said was ok to keep(but the network guys were not allowed to remove the mdm stuff). I would have turned it in if they had required it.
I now have another laptop with my new company whose policies are very strict and I'm not sure this whole process would work. They even block me being able to do Time Machine backups. :(