How to render invisible objects casting their z-depth alongside other visible objects
Using render layers might help you.
I have created these two planes, and put them in seperate layers. The light grey in layer 1, and the blue in layer 2. In the render layer tab settings there is a "mask layer" where I chose layer 2 as a mask layer.



Please note that the shadows of layer 1 still render, you can remove these by unchecking the "shadow" box in the "cycles settings" under the object tab

finished result, a masked grey plane in all its glory

If the blue plane on top is moved below the grey plane. It will not mask the plane.