A search for the Higgs boson decaying into a pair of charm quarks is presented. The analysis uses proton-proton collisions to target the production of a Higgs boson in association with a leptonically decaying or boson. The dataset delivered by the LHC at a centre-of-mass energy of TeV and recorded by the ATLAS detector corresponds to an integrated luminosity of 139 fb. Flavour-tagging algorithms are used to identify jets originating from the hadronisation of charm quarks. The analysis method is validated with the simultaneous measurement of and production, with observed (expected) significances of () standard deviations above the background-only prediction for the process and () standard deviations for the process. The search yields an observed (expected) upper limit of () times the predicted Standard Model cross-section times branching fraction for a Higgs boson with a mass of 125 GeV, corresponding to an observed (expected) constraint on the charm Yukawa coupling modifier , at the 95% confidence level. A combination with the ATLAS analysis is performed, allowing the ratio to be constrained without assumptions about the width of the Higgs boson. The ratio is constrained to be at the 95% confidence level, smaller than the ratio of the - and -quark masses, and therefore determines the Higgs-charm coupling to be weaker than the Higgs-bottom coupling at the 95% confidence level.