Observation of an ultra-high-energy cosmic neutrino with KM3NeT