Costa opened the scoring in the first minute and completed his hat-trick with a 45th-minute penalty.
Joao Felix, a £113m summer signing, also scored his first goal for the club as Atletico led 5-0 at the break.
Costa added his fourth goal six minutes after the restart, before both he and Real's Dani Carvajal were red carded for fighting in the 61st minute.
Angel Correa, on for the injured Alvaro Morata, was also on target in the first half, while Vitolo added the seventh in the 70th minute.
It took until they were 6-0 down before Real got on the scoresheet through Nacho, while Karim Benzema and Javi Hernandez both scored late on.
A stunned Real coach Zinedine Zidane remarked afterwards, “What happened is, we started the game very poorly. In a top-level match such as this, we had a very bad start. We were 2-0 inside eight minutes and didn't show signs of changing anything at all. It was a very tough first half, we never got into the game. We just really lacked the intensity you need at this level.
“We know they scored seven goals and we can't allow that to happen. The players are well aware and they're disappointed. We don't need to dwell on it, this is a pre-season game. They were better in every respect and that's all there is to it.
“We'll be motivated, I have no doubt about it. I'm convinced we're going to have a good season. We can't be pleased with today's defeat, that much is clear. But I'm convinced I've got a team here that is going to compete at the top level. We need to rest up a bit and start thinking about the 17th of August."