Recent X-ray observations of galaxy clusters show that the distribution of intra-cluster medium (ICM) metallicity is remarkably uniform in space and time. In this paper, we analyse a large sample of simulated objects, from poor groups to rich clusters, to study the dependence of the metallicity and related quantities on the mass of the systems. The simulations are performed with an improved version of the Smoothed-Particle-Hydrodynamics texttt{GADGET-3} code and consider various astrophysical processes including radiative cooling, metal enrichment and feedback from stars and active galactic nuclei (AGN). The scaling between the metallicity and the temperature obtained in the simulations agrees well in trend and evolution with the observational results obtained from two data samples characterised by a wide range of masses and a large redshift coverage. We find that the iron abundance in the cluster core ($r<0.1R_{500}$) does not correlate with the temperature nor presents a significant evolution. The scale invariance is confirmed when the metallicity is related directly to the total mass. The slope of the best-fitting relations is shallow ($betasim-0.1$) in the innermost regions ($r<0.5R_{500}$) and consistent with zero outside. We investigate the impact of the AGN feedback and find that it plays a key role in producing a constant value of the outskirts metallicity from groups to clusters. This finding additionally supports the picture of early enrichment.