  Yttrium (Y), a key s-process element, is commonly used in nucleosynthesis
studies and as a Galactic chemical clock when combined with magnesium (Mg). We
study the applicability of the previously assumed LTE line formation assumption
in Y abundance studies of main-sequence and red giant stars, and probe the
impact of NLTE effects on the [Y/Mg] ratio, a proposed stellar age indicator.
We derive stellar parameters, ages, and NLTE abundances of Fe, Mg, and Y for 48
solar analogue stars from high-resolution spectra acquired within the Gaia-ESO
survey. For Y, we present a new NLTE atomic model. We determine a solar NLTE
abundance of A(Y)$_{\rm NLTE}=2.12\pm0.04$ dex, $0.04$ dex higher than LTE.
NLTE effects on Y abundance are modest for optical Y II lines, which are
frequently used in Sun-like stars diagnostics. NLTE has a small impact on the
[Y/Mg] ratio in such stars. For metal-poor red giants, NLTE effects on Y II
lines are substantial, potentially exceeding $+0.5$ dex. For the
Gaia/4MOST/WEAVE benchmark star, HD 122563, we find the NLTE abundance ratio of
[Y/Fe]$_{\rm NLTE}=-0.55\pm0.04$ dex with consistent abundances obtained from
different Y II lines. NLTE has a differential effect on Y abundance diagnostics
in late-type stars. They notably affect Y II lines in red giants and very
metal-poor stars, which are typical Galactic enrichment tracers of
neutron-capture elements. For main-sequence stars, NLTE effects on optical
diagnostic Y II lines remain minimal across metallicities. This affirms the
[Y/Mg] ratio's reliability as a cosmochronometer for Sun-like stars.
