• An important source of background in direct searches for low-mass dark matter particles are the energy deposits by small-angle scattering of environmental $\gamma$ rays. We report detailed measurements of low-energy spectra from Compton scattering of $\gamma$ rays in the bulk silicon of a charge-coupled device (CCD). Electron recoils produced by $\gamma$ rays from $^{57}$Co and $^{241}$Am radioactive sources are measured between 60 eV and 4 keV. The observed spectra agree qualitatively with theoretical predictions, and characteristic spectral features associated with the atomic structure of the silicon target are accurately measured for the first time. A theoretically-motivated parametrization of the data that describes the Compton spectrum at low energies for any incident $\gamma$-ray flux is derived. The result is directly applicable to background estimations for low-mass dark matter direct-detection experiments based on silicon detectors, in particular for the DAMIC experiment down to its current energy threshold.