New signings Shinji Okazaki and Christian Fuchs were given some game time by the Italian, who replaced Nigel Pearson as manager.
The Premier League side went behind from the spot after Liam Moore was penalised for handball and Alan Power fired in the penalty.
Riyad Mahrez pulled one back before the break, and late goals from Andrej Kramaric and Jamie Vardy gave Ranieri a win in his first game in charge.
Southampton continued their pre-season preparations in style as they hit 10 goals against Dutch side KVV Quick ’20.
Graziano Pelle registered a first-half hat-trick, while Jay Rodriguez and Steven Davis both scored twice in the opening 45 minutes as Ronald Koeman’s men went in seven up at the break.
Jordan Turnbull and Juanmi added one each from the bench, before Rodriguez wrapped up his hat-trick in an impressive Saints display, which also included a first start for Jordy Clasie.
Aston Villa earned their first win of the summer as they beat Swindon 2-0 at the County Ground.
Tim Sherwood handed a debut to full-back Jordan Amavi, who tasted victory as Scott Sinclair put Villa in front before Jerell Sellars added one late on to seal victory.
A youthful Bournemouth side lost 2-1 at Salisbury, but Harry Cornick impressed as Eddie Howe watched on.
The U21 striker fired Bournemouth ahead midway through the first half, but the home side came back to win thanks to goals from Patrick Nolan and Mark Ford.
West Ham succumbed to their first pre-season defeat as they went down 1-0 at Colchester United.
Former Hammer George Moncur scored the only goal of the game as the Premier League outfit went with a youthful line-up.