Los Blancos had used already used all three substitutes in the encounter when, in the 73rd minute, Ramos had a brief word with the referee before disappearing down the tunnel.
The Spaniard returned to the field of play moments later, shortly before Cristiano Ronaldo made sure of the three points with his second goal of the game.
Asked about the incident at his press conference after the game, Zidane told reporters: "He shit himself a little bit. I think Sergio had to take a shit. He went to the toilet and returned in a minute."
The result saw Ramos's side move four points behind second-placed Atletico Madrid in the La Liga table.