Observation of time-domain modulation of free-electron-laser pulses by multipeaked electron-energy spectrum