Some custom maps use special brush entities to deflect and block bullets and projectiles. You could seal a doorway with an invisible func_brush, and use triggers to turn it off or on when players attempt to walk through it. You can also cover a doorway in an invisible func_physboxmultiplayer and it will block shots. Each trick has its pros and cons so you will need to experiment.
If you are making a map designed for standard TF2 play you should work on preventing spawn camping by designing your map to minimise it. You could look at how long it takes teams to reach the enemy spawn and compare it with respawn wave times, and design the architecture on routes toward it so that they gave scant cover and pickups to make it challenging.
A little bit of spawn camping is okay in my opinion, but only for a short time and not when there isn't much time left on the clock. Occasional spawn camping by a small number of players can feel rewarding for those who get to do it because they feel like they have done a good job beating the attackers back. Being spawn camped isn't fun and is annoying when there are good hiding spots for the people who are camping. It should only take a little extra effort or some coordination to clear spawn campers out, which rewards those players for responding to a threat.