So I looked into this. It's actually a lot more complex than I thought. One thing I did discover is shadow to opacity, which only renders the shadowed regions and not the rest of the mesh. So this solves the invisible table issue without a custom shader (it's in the material flags).
However, clipping the shadow may be very difficult or impossible. Because the way shadow mapping works (let's say for a directional light to make it simple) it renders all the shadow casting objects into a depth buffer. Then reads from the shadow depth buffer and the screen depth buffer to compare them to see what is blocked. AFAIK it is not possible with this method to render half of an object. An object is either casting a shadow or not. And once it is in the depth map, there is no way to know what object belongs to what, or any way to erase part of an object. So this is tricky.
At one point I was developing this screen space shadow shader. I never got it 100% working, but I did like the idea and years later they started adding it to games (Cyberpunk 2077 uses it for example). It's sort of like ray tracing but in screen space. So you could cast rays from the light, see if they get blocked, and then continue the ray until the next object, if it hits you know that pixel is in a shadow. This is much slower than shadowing mapping, but I think would be fast enough for your game, since you have limited dynamic objects and can limit the angle and coverage of the light.
However, that still doesn't solve how you erase the shadow. We would need a way to mark an object as invisible and or non-shadow casting and then if a ray hit that sort of object (the invisible object) then the ray would be consumed and disappear. This would in effect, allow the cup or whatever to cast shadows on the table, and also partial shadows on the floor (without the table itself casting a shadow). But I need to figure out how to differentiate the invisible objects (since this works in screen space, we only have the color and depth of the final image). Possibly I could write to the alpha channel, I only really need 1-bit of information. I'm not sure if that would mess up the rendering at all, but I should be able to fix it in post.
Though this still depends on being able to solve the whole screen space shadow thing, which I never got 100% working (but I know the idea works, I've seen videos). I can look into it, but it's a more involved project. It may take about 1 week if I wasn't working on other things. Here's a video to show you that it can work.
Not sure what your level of shading programming is, but it's kind of complex. You can look into it if you want, but I wanted to figure it out at some point, so if you can wait a few weeks I can probably get it working.