Least-Squares Joint Diagonalization of a matrix set by a congruence