Astrophysical collisionless shocks are among the most powerful particle accelerators in the Universe. Generated by violent interactions of supersonic plasma flows with the interstellar medium, supernova remnant shocks are observed to amplify magnetic fields1 and accelerate electrons and protons to highly relativistic speeds2-4. In the well-established model of diffusive shock acceleration5, relativistic particles are accelerated by repeated shock crossings. However, this requires a separate mechanism that pre-accelerates particles to enable shock crossing. This is known as the `injection problem', which is particularly relevant for electrons, and remains one of the most important puzzles in shock acceleration6. In most astrophysical shocks, the details of the shock structure cannot be directly resolved, making it challenging to identify the injection mechanism. Here we report results from laser-driven plasma flow experiments, and related simulations, that probe the formation of turbulent collisionless shocks in conditions relevant to young supernova remnants. We show that electrons can be effectively accelerated in a first-order Fermi process by small-scale turbulence produced within the shock transition to relativistic non-thermal energies, helping overcome the injection problem. Our observations provide new insight into electron injection at shocks and open the way for controlled laboratory studies of the physics underlying cosmic accelerators.