If you don’t want the members of group A To know that there are other members on the forum who are not in group A then your best option is to have two forums.
You might be able to mute the members of group A for members of group B, but there isn’t a good way to do that that I’m aware of. The solutions that I can think of are harder than having a second forum.