So instead of querying a recursive dns service like cloudflare or google you query the 13 root DNS servers such as https://a.root-servers.org/
This way no data goes through 3rd parties. However, this is a poor idea since none of the root servers support encrypted DNS queries.
You can use DoH or DoT. DoT already has its own port 853 which can be firewall blocked. So then DoH can be harder to block because it uses port 443 same as HTTPS hence the name.
So the best way of doing it is either using ODoH which uses a proxy to ask on your behalf, but the proxy knows your IP address.
DNS privacy is in my opinion a farce because someone knows your IP address and someone knows your queries. The best way is to hide in numbers and the external promise of no logs queries.
So for me, I just pick the fastest encrypted no logging DNS servers. And the top 3 for my location is
https://freedns.controld.com/uncensored
https://95.85.95.85/dns-query
I used this tool to help pick the fastest encrypted servers.
https://center2055.github.io/DNS-Hop/
Good luck and happy labbing