Cosmic γ-ray background from structure formation in the intergalactic medium