I dont use Pihole but could you not have Pihole forward external requests onto your Unifi which then uses secure DNS, yes your internal lookups would be clear text for someone monitoring DNS traffic on your LAN but then any external requests would be encrypted.
Cloudflare supports encrypted DNS: https://developers.cloudflare.com/1.1.1.1/encryption/ they also support DNS with malware and adult content blocks.
Cloudflare supports encrypted DNS: https://developers.cloudflare.com/1.1.1.1/encryption/ they also support DNS with malware and adult content blocks.