Sharma, who has been selected for India's remaining two ODIs against Sri Lanka and the tour of Australia, took three wickets before hitting a 32-run cameo in his team's victory.
Railways raced past Madhya Pradesh's 241 for five with 14 balls to spare.
It was Railways' third win in as many games while Madhya Pradesh suffered their second loss in a row.
Wicketkeeper-batsman Naman Ojha, who finds himself in the squad for the first Test against Australia, struck a solid 61 off 86 balls in a losing cause.
Opener Asad Pathan made Railways' chase much easier by hammering 63 off 36 balls.
Brief scores: Madhya Pradesh 241 for five (Naman Ojha 61, Jalaj Saxena 61; Karn Sharma 3/47) lost to Railways by five wickets (Asad Pathan 63, Karna Sharma 32 not out; Ishwar Pandey 2/49, Jalaj Saxena 2/37).