This is only possible with projectiles (with func_clip_vphysics), any other stuff like bullets and flames cannot be blocked team-specific
Though a glitchy way could be using displacements, simply make only 1 side of a brush a displacement, that way stuff coming from the displacement side will bounce into the displacement, but stuff coming from the other side will go through it
I think this will work, as there was a glitch in gravelpit where sentries built below the displacement ground could hit people, while people above the ground could not hit it back
When people ask questions like this i always wonder what possible affective use could they have in legit TF2 gameplay...
Fortunately people aren't forced into playing only legit tf2 gameplay
There's mods in which things like this can be interesting