The magnesium Mg2 index as an indicator of metallicity in elliptical galaxies