Ferrari's Carlos Sainz managed to beat Max Verstappen, Lando Norris and team-mate Charles Leclerc to take pole in Mexico City.