Context. The upcoming generation of optical spectrographs on four meter-class telescopes, with their huge multiplexing capabilities, excellent spectral resolution, and unprecedented wavelength coverage, will provide high-quality spectra for thousands of galaxies. These data will allow us to examine of the stellar population properties at intermediate redshift, an epoch that remains unexplored by large and deep surveys. Aims. We assess our capability to retrieve the mean stellar metallicity in galaxies at different redshifts and signal-to-noise ratios (S/N), while simultaneously exploiting the ultraviolet (UV) and optical rest-frame wavelength coverage. Methods. The work is based on a comprehensive library of spectral templates of stellar populations, covering a wide range of age and metallicity values and built assuming various star formation histories, to cover an observable parameter space with diverse chemical enrichment histories and dust attenuation. We took into account possible observational errors, simulating realistic observations of a large sample of galaxies carried out with WEAVE at the William Herschel Telescope at different redshifts and S/N values. We measured all the available and reliable indices on the simulated spectra and on the comparison library. We then adopted a Bayesian approach to compare the two sets of measurements in order to obtain the probability distribution of stellar metallicity with an accurate estimate of the uncertainties. Results. The analysis of the spectral indices has shown how some mid-UV indices, such as BL3580 and Fe3619, can provide reliable constraints on stellar metallicity, along with optical indicators. The analysis of the mock observations has shown that even at S/N = 10, the metallicity can be derived within 0.3 dex, in particular, for stellar populations older than 2 Gyr. The S/N value plays a crucial role in the uncertainty of the estimated metallicity and so, the differences between S/N = 10 and S/N = 30 are quite large, with uncertainties of ~0.15 dex in the latter case. On the contrary, moving from S/N = 30 to S/N = 50, the improvement on the uncertainty of the metallicity measurements is almost negligible. Our results are in good agreement with other theoretical and observational works in the literature and show how the UV indicators, coupled with classic optical ones, can be advantageous in constraining metallicities. Conclusions. We demonstrate that a good accuracy can be reached on the spectroscopic measurements of the stellar metallicity of galaxies at intermediate redshift, even at low S/N, when a large number of indices can be employed, including some UV indices. This is very promising for the upcoming surveys carried out with new, highly multiplexed, large-field spectrographs, such as StePS at the WEAVE and 4MOST, which will provide spectra of thousands of galaxies covering large spectral ranges (between 3600 and 9000 Å in the observed frame) at relatively high S/N (>10 Å−1).