Long γ-ray bursts are associated with energetic, broad-lined, stripped-envelope supernovae1,2 and as such mark the death of massive stars. The scarcity of such events nearby and the brightness of the γ-ray burst afterglow, which dominates the emission in the first few days after the burst, have so far prevented the study of the very early evolution of supernovae associated with γ-ray bursts3. In hydrogen-stripped supernovae that are not associated with γ-ray bursts, an excess of high-velocity (roughly 30,000 kilometres per second) material has been interpreted as a signature of a choked jet, which did not emerge from the progenitor star and instead deposited all of its energy in a thermal cocoon4. Here we report multi-epoch spectroscopic observations of the supernova SN 2017iuk, which is associated with the γ-ray burst GRB 171205A. Our spectra display features at extremely high expansion velocities (around 115,000 kilometres per second) within the first day after the burst5,6. Using spectral synthesis models developed for SN 2017iuk, we show that these features are characterized by chemical abundances that differ from those observed in the ejecta of SN 2017iuk at later times. We further show that the high-velocity features originate from the mildly relativistic hot cocoon that is generated by an ultra-relativistic jet within the γ-ray burst expanding and decelerating into the medium that surrounds the progenitor star7,8. This cocoon rapidly becomes transparent9 and is outshone by the supernova emission, which starts to dominate the emission three days after the burst.