Firewall by script: How to configure * and [N]?

Not with qvm-firewall.

You could try with iptables and pattern matching (aka regular expression aka regex).
Also note, from https://www.qubes-os.org/doc/firewall/#network-service-qubes:

In particular, if you want to ensure proper functioning of the Qubes firewall, you should not tinker with iptables or nftables rules in such qubes (a qube that is used to run the Qubes firewall service (usually sys-firewall))

Some starting point.
https://www.startpage.com/do/search?q=iptables+regex
https://www.startpage.com/do/search?q=iptables+pattern+match
spoiler: the algo seems to not be regex.
https://askubuntu.com/questions/1001847/how-to-use-regular-expression-with-iptables