How can I customise quad depth testing?

I have some very simple billboard sprites that I’m mixing with some simple 3D polygonal terrain.
I have some cliffs that are near the sprites. Currently when the sprites are too close, they clip into the terrain, like the diagram below.

What I’d like to happen is for them to “pop” so they’re either completely in front of or completely behind other meshes, whether that’s other billboard sprites, or pieces of the ground/cliffs. Probably based on the world position of the bottom-center of the billboard sprite, compared against some part of the other mesh…?

Is there a way of achieving this? As far as my limited graphics knowledge goes, it seems it’s impossible… is there a way?