I'm not aware if you can do it the way you mention, but you can used NextDNS and it pretty much cleans most of the ads (I actually haven't seen an ad in a very long time).
I am pretty active in the blocklist community, co-maintain a FOSS network monitor and firewall for Android, was a contributor to AOSP, and run a public DoH/DoT resolver; to me, the writing has been on the wall for the past few years. Plugins like uBlockOrigin, alt web-based front-ends like Invidious, and reverse-engineered apps like YouTube ReVanced will most likely be the only options left in the not so distant future.
If it ever interests you: https://nextdns.io/?from=d6jchbnv (my affiliate link).