We use high-resolution relativistic MHD simulations coupled with a radiative transfer code to compute multiwavelength afterglow light curves of magnetized ejecta of gamma-ray bursts interacting with a uniform circumburst medium. The aim of our study is to determine how the magnetization of the ejecta at large distance from the central engine influences the afterglow emission, and to assess whether observations can be reliably used to infer the strength of the magnetic field. We find that, for typical parameters of the ejecta, the emission from the reverse shock peaks for magnetization $\sigma_0 \sim 0.01 - 0.1$ of the flow, and that it is greatly suppressed for higher $\sigma_0$. The emission from the forward shock shows an achromatic break shortly after the end of the burst marking the onset of the self-similar evolution of the blast wave. Fitting the early afterglow of GRB 990123 and 090102 with our numerical models we infer respective magnetizations of $\sigma_0 \sim 0.01$ and $\sigma_0 \sim 0.1$ for these bursts. We argue that the lack of observed reverse shock emission from the majority of the bursts can be understood if $\sigma_0 \simmore 0.1$, since we obtain that the luminosity of the reverse shock decreases significantly for $\sigma_0 \sim 1$. For ejecta with $\sigma_0 \simmore 0.1$ our models predict that there is sufficient energy left in the magnetic field, at least during an interval of ~10 times the burst duration, to produce a substantial emission if the magnetic energy can be dissipated (for instance, due to resistive effects) and radiated away.