Material Occlude/Cut Objects that Pass Through it

I want to create a material for my mannequin so whenever an object clips through it, it will get occluded (something like the image attached). And yes I’ve tried “BoxMask” & “SphereMask” but they don’t work well for my humanoid mannequin. Is there a way to do this using Custom Depth?