  Motivated by the anomalous dust-to-metal ratios derived in the literature for
gamma-ray burst (GRB) damped Lyman-alpha absorbers (DLAs), we measure these
ratios using the dust-depletion pattern observed in UV/optical afterglow
spectra associated with the ISM at the GRB host-galaxy redshifts. Our sample
consists of 20 GRB absorbers and a comparison sample of 72 QSO-DLAs with
redshift 1.2 < z < 4.0 and down to Z = 0.002 Z_Sol metallicities. The
dust-to-metal ratio in QSO- and GRB-DLAs increases both with metallicity and
metal column density, spanning ~10--110% of the Galactic value and pointing to
a non universal dust-to-metal ratio. The low values of dust-to-metal ratio
suggest that low-metallicity systems have lower dust fractions than typical
spiral galaxies and perhaps that the dust in these systems is produced
inefficiently, i.e. by grain growth in the low-metallicity regime with
negligible contribution from supernovae (SNe) and asymptotic giant branch (AGB)
stars. On the other hand, some GRB- and QSO-DLAs show high dust-to-metal ratio
values out to z ~ 4, requiring rapid dust production, such as in SN ejecta, but
also in AGB winds and via grain growth for the highest metallicity systems.
GRB-DLAs overall follow the dust-to-metal-ratio properties of QSO-DLAs, GRBs
probing up to larger column and volume densities. For comparison, the
dust-to-metal ratio that we derive for the SMC and LMC are ~82--100% and ~98%
of the Galactic value, respectively. The literature dust-to-metal ratio of the
low-metallicity galaxy I Zw 18 (< 37%) is consistent with the distribution that
we find. The dust extinction Av increases steeply with the column density of
iron in dust, N(Fe)dust, calculated from relative metal abundances, confirming
that dust extinction is mostly occurring in the host galaxy ISM. Most GRB-DLAs
display log N(Fe)dust > 14.7, above which several QSO-DLAs reveal H2
(abridged).
