I run Safari on three Mac OS versions (Mojave, Catalina and Big Sur) and have not found this to be the case. The behavior you are reporting is not baked into MacOS or Safari.
I would contact the author of the article and ask them what front-end DoH proxy they are using.
I put some wireshark traces on the link I posted.
my device has the same name internally and externally with an Internal IP and an external IP.
as soon as I access to the device it swap to the external IP, even the ping is going to the external IP and the only way to comeback to the internal one is to flush the DNS