Finding linear transformation under which distance matrices are similar
I think what you are searching is related to metric learning. PCA is an unsupervised learning method but there are equivalent method in which you can introduce label information to learn the best linear transformation that maximize the distance between data from different labels.
http://contrib.scikit-learn.org/metric-learn/introduction.html#:~:text=Distance%20metric%20learning%20(or%20simply,%2C%20clustering%2C%20information%20retrieval).