Kohli and a few other Indian players fumed at South Africa broadcaster, SuperSport, after Elgar got an LBW reprieve following the DRS review. The India captain walked up to the stump mic and said, "Focus on your team while they shine the ball. Not just the opposition. Trying to catch people all the time."
Umpire Marius Erasmus had earlier given Elgar out but the ball-tracking technology showed that the ball had missed the stumps, and the decision was overturned on review.
Gambhir termed Kohli's reaction exaggerated and immature. The former player said that such reaction sets a bad example for budding cricketers.
Also Read | Brazil boss Tite names Alves, Coutinho for World Cup qualifiers
"Kohli is very immature. It's worst for an Indian captain to say like this in stumps. By doing this you will never be an idol to youngsters," Gambhir told Star Sports.
"This is really bad. What Kohli did, going near the stump mic and reacting in that manner, that is really immature. This is not what you expect from an international captain, from an Indian captain. Then technology isn't in your hand," said Gambhir.
Gambhir drew comparisons with Elgar and how calmly he reacted to India batter Mayank Agarwal's reprieve during the inaugural Test at Centurion.
"Then you have reacted in the same manner when there was a caught-behind appeal on the leg-side, neither did Dean Elgar react in that manner. During that Mayank Agarwal appeal, it looked out from the naked eye, but Elgar did not react in that manner," said Gambhir.
Also Read | U-19 World Cup: After two big warm-up losses, West Indies take on Australia in opener
Gambhir wants chief coach Rahul Dravid to have a word with Kohli to curb such behaviour.
"No matter what you say, stuff like he plays with his heart on his sleeve, this reaction was an exaggerated one and you can't be a role model in this manner. No budding cricketers would want to see this kind of a reaction, especially from the Indian captain. No matter the result in this Test match, this is not what you expect from a Test captain who has led the team for so long.
"I hope Rahul Dravid has a word with him, because the type of captain Dravid was, he would have never reacted in this manner."
Elgar eventually departed before stumps as South Africa went two down, needing 111 runs to win the series with eight wickets in hand.
Elgar scored 30 off 96 deliveries before pace bowler Jasprit Bumrah accounted for his wicket.
India Test vice-captain KL Rahul too expressed his displeasure over Elgar's reprieve, saying, "It's the whole country against 11 guys, while Ravichandran Ashwin, who was deprived of the wicket, was quoted as saying by crickettracker.com that, "You should find better ways to win, SuperSport."
Former South African pace bowling great Shaun Pollock said, "India was desperate to get the wicket and the emotion overflowed after that. The ball pitched in line and bounced and Elgar got a good stride forward. With that stride, it was going to be close.
"Indians went over the top. Hawk-eye is something you rely on for decision-making. It's an independent body. They do their level best with everything they have got. They have got their own cameras. I can understand the disappointment because they wanted the wicket but I think they went over the top a little bit," he added.