You can achieve what you wish, but not the way you're thinking of doing it.
If you want to output a common depth for all fragments belonging to a primitive, you can add an extra vertex attribute - say, the midpoint of the primitive - which can be a per-instance attribute (if using instancing) or an extra per-vertex attribute (or even set via a glVertexAttrib3f call). The method used to set it doesn't matter much; what's important is that it has the same value for each vertex.
Duplicate your per-vertex calculations for position and for this extra attribute, then pass the extra attribute to your fragment shader as a varying. From there you just need to output depth from your fragment shader based on this extra attribute.
At this stage you're probably worrying a little about having to do the extra redundant calculations per-vertex, but this is not going to be a big deal compared to the overhead of outputting depth from your fragment shader, which will disable early-depth-testing for that shader, and which will be a requirement anyway if you want all fragments to have common depth.