@jc95, welcome to the community!
It would be simpler to install Adblock and add the domains to the blacklist.
There's also a method to directly load the domain responses into an ipset for blocking, but I'm not deeply familiar with that - there should be some threads on it.
Since a domain can have multiple A and AAAA records, it's not really feasible to make rules like that - even if such rules worked.