If you want the part of the polygon below the surface to be properly occluded based on the depth value at different points, it will be more difficult. When zoomed out, -100m is small relative to the depths in the scene, so the depth buffer may not have enough precision for an accurate depth test. One option would be to split the polyline into above- and below-ground segments by pre-computing the points where the line intersects the surface.
Do you have an idea of how close (in meters) the camera is to the line before the depthFailAppearance works as you expect?
You may need to pre-compute the points where the line intersects the surface, and perhaps split the line into separate Polylines with different appearances. The depth buffer is single-precision at best, or worse in many cases. When zoomed out, small differences won’t be resolvable via standard depth testing.