Evidence for a cosmological effect in γ-ray spectra of BL Lacertae