How do I make an object cast shadows but be invisible in the render?
In Cycles or Eevee, that can be:



It uses the light path, testing if it is a ray from the object to the camera: if yes, the transparent shader is used.

For Eevee, you need to set the blend mode to alpha blend: