It’s possible to combine Pi-Hole, a simple network level ad blocker and Cloudflared, a DNS over HTTPS client from Cloudflare to produce a DNS server that can block ads at the DNS level, resolve local hostnames and encrypt external DNS queries.
This page has a great tutorial on how to get everything up and running:
https://www.cyberciti.biz/faq/configure-ubuntu-pi-hole-for-cloudflare-dns-over-https/