No, that doesn't block YouTube ads (for example) and with DNS over Https will stop working soon anyway.
I am not sure how the transport layer affects the DNS that is used, but I think you are mistaken. If you require an off-site DNS ad blocking solution compatible with DoH, try NextDNS.
StopTheMadness on Safari allows you to rewrite URLs to alternates.
For YouTube you can rewrite to an invidious instance. No ads.