Ferroelastic phase transition, domain pattern and metastability in diluted lead phosphate-type crystals