Observation of associated production of a Z boson with a D meson in the forward region