I don't think it would do any harm to the locomotive either it's a diesel or electric as the total locomotive is grounded through rail also there are lightning arresters on loco which would take care of lightning. The surface might be slightly burnt where the Lightning would have struck. Never experienced one as well. Hope it cleared you doubt