I think there is more to it than the
@kimbyd example. Consider such an expanding thermal gas isolated in a region of an asymptotically flat spacetime rather than in a box (which is also equivalent, to very high accuracy, to a expanding gas blob reasonably isolated between galaxies. In this case (the asymptotically flat spacetime), the energy is exactly conserved as long as radiation is accounted for. The ADM energy, which includes the radiation, remains constant. The Bondi energy, which excludes escaping radiation (EM plus gravitational), decreases.
However, our universe is not asymptotically flat. Neither ADM energy nor Bondi energy can be defined for a realistic cosmology. In simple terms, for a closed universe, there is no outside boundary to sum over, and for an open universe, there is no 'quiescence at infinity' to allow an invariant summing up.
The key point, IMO is that conservation of energy is 'essentially' exact in GR up to scales considerably bigger than a galaxy, over long time scales, but breaks down over cosmological distances and times, because the approximation of asymptotically flat spacetime embedding becomes less and less accurate.
Thus, to my mind, the correct statement isn't 'energy conservation is violated' (which is
not what
@kimbyd said, but some careless authors have), but that total energy cannot be meaningfully defined over very large scales in a realistic cosmology (FLRW, or anything else that is not asymptotically flat).