Gamma-ray line signatures can be expected in the very-high-energy (E(γ)>100 GeV) domain due to self-annihilation or decay of dark matter (DM) particles in space. Such a signal would be readily distinguishable from astrophysical γ-ray sources that in most cases produce continuous spectra that span over several orders of magnitude in energy. Using data collected with the H.E.S.S. γ-ray instrument, upper limits on linelike emission are obtained in the energy range between ∼ 500 GeV and ∼ 25 TeV for the central part of the Milky Way halo and for extragalactic observations, complementing recent limits obtained with the Fermi-LAT instrument at lower energies. No statistically significant signal could be found. For monochromatic γ-ray line emission, flux limits of (2 × 10(-7) -2 × 10(-5)) m(-2) s(-1) sr(-1) and (1 × 10(-8) -2 × 10(-6)) m(-2) s(-1)sr(-1) are obtained for the central part of the Milky Way halo and extragalactic observations, respectively. For a DM particle mass of 1 TeV, limits on the velocity-averaged DM annihilation cross section ⟨σv⟩(χχ → γγ) reach ∼ 10(-27) cm(3)s(-1), based on the Einasto parametrization of the Galactic DM halo density profile.