I don't see why you shouldn't be able to do this. You just have to define a sampler with the depthmap as a texture. You should however keep in mind that the depthmap is then from the previous frame.
However, I think it would be easier to transform the objects vertices in a vertex shader to camera space. You then already have the depth of the objects vertices in their z coordinate. Compared to the depthmap solution you have up to date data and don't need to do the texture lookup. So the depthmap solution is something like a detour for something you need to do anyways in a vertex shader.