in case you have configured the VLANs as VLAN interfaces on a RouterBoard, just add the VLAN interfaces in a interface list and create a block rule in forward chain with this interface list as source and destination.
Edit: I just saw the answer posted before mine. This is the simplest solution, but with interface lists you’re a little more flexible. Apart from that, the solution provided is fine.