Alternatively, you can do something like this:
*$denyallow=example.org|example.com
Blocks everything except example.org and example.com.
Works in AdGuard Home, AdGuard DNS or any other AG product with DNS filtering capabilities:
https://adguard-dns.io/kb/general/dns-filtering-syntax/