We use dark matter haloes identified in the MARENOSTRUM UNIVERSEx and galaxy groups identified in the Sloan Digital Sky Survey Data Release 7 (SDSS DR7) galaxy catalogue to study the relation between halo shape and halo dynamics, parametrizing the mass of the systems. A strong shape–dynamics correlation, independent of mass, is present in the simulation data, which we find to be due to different halo-formation times. Early formation-time haloes are, at the present epoch, more spherical and have higher velocity dispersions than late formation-time haloes. The halo shape–dynamics correlation survives the projection into two dimensions (i.e. between projected shape and 1D velocity dispersion), albeit weaker. A similar shape–dynamics correlation, independent of mass, is also found in the SDSS DR7 groups of galaxies, and in order to investigate its cause we have tested and used, as a proxy of the group formation time, a concentration parameter. We have found, as in the case of the simulated haloes, that less concentrated groups, corresponding to late formation times, have lower velocity dispersions and higher elongations than groups with higher values of concentration, corresponding to early formation times.