We use the IllustrisTNG simulations to investigate the evolution of the mass-metallicity relation (MZR) for star-forming cluster galaxies as a function of the formation history of their cluster host. The simulations predict an enhancement in the gas-phase metallicities of star-forming cluster galaxies (10^9< M_star<10^10 M_sun) at z<1.0 in comparisons to field galaxies. This is qualitatively consistent with observations. We find that the metallicity enhancement of cluster galaxies appears prior to their infall into the central cluster potential, indicating for the first time a systematic chemical pre-processing signature for {it infalling} cluster galaxies. Namely, galaxies which will fall into a cluster by z=0 show a ~0.05 dex enhancement in the MZR compared to field galaxies at z<0.5. Based on the inflow rate of gas into cluster galaxies and its metallicity, we identify that the accretion of pre-enriched gas is the key driver of the chemical evolution of such galaxies, particularly in the stellar mass range (10^9< M_star<10^10 M_sun). We see signatures of an environmental dependence of the ambient/inflowing gas metallicity which extends well outside the nominal virial radius of clusters. Our results motivate future observations looking for pre-enrichment signatures in dense environments.