Suppose I have a square n*n, symmetric matrix with positive elements and zero diagonal.

For this to be considered a proper distance metric between n points, the triangle inequality needs to be satisfied (the other requirements follow from the definition).

Is there some standard measure that says to what extent this property is violated by a given matrix ?

In particular, is there a measure that is fast to compute and can such a thing be optimized for ? I.e. obtain solution X that is "as close to being a metric as possible".