Uh you can’t really do this with yunohost’s firewall, it’s pretty “basic” and only able to allow/deny ports…
But it can be extended using some iptables commands to add whatever you want … You’ll need to create a custom hook called post_iptable_rules :
nano /etc/yunohost/hooks.d/post_iptable_rules/my_custom_rules
then the content you put in it is a bash script where you can put arbitrary commands executed each the firewall is regenerated