  A search has been performed for heavy resonances decaying to ZZ or ZW and for
axion-like particles (ALPs) mediating nonresonant ZZ or ZH production, in final
states with two charged leptons ($\ell$ = e, $\mu$) produced by the decay of a
Z boson, and two quarks produced by the decay of a Z, W, or Higgs boson H. The
analysis is sensitive to resonances with masses in the range 450 to 2000 GeV.
Two categories are defined corresponding to the merged or resolved
reconstruction of the hadronically decaying boson. The search is based on data
collected during 2016-2018 by the CMS experiment at the LHC in proton-proton
collisions at a center-of-mass energy of 13 TeV, corresponding to an integrated
luminosity of 138 fb$^{-1}$. No significant excess is observed in the data
above the standard model background expectation. Upper limits on the production
cross section of heavy, narrow spin-2 and spin-1 resonances are derived as
functions of the resonance mass, and exclusion limits on the production of bulk
graviton particles and W$'$ bosons are calculated in the framework of the
warped extra dimensions and heavy vector triplet models, respectively. In
addition, upper limits on the ALP-mediated diboson production cross section and
ALP couplings to standard model particles are obtained in the framework of
linear and chiral effective field theories. These are the first limits on
nonresonant ALP-mediated ZZ and ZH production obtained by the LHC experiments.
