It is technically possible to have a single locomotive with duel power technology for a seamless operation of train. It is like a Diesel locomotive with a pantograph and in electrified route it should draw power from overhead traction line and in non-electrified route it runs like a normal diesel locomotive.
Similar locomotives are manufactured by Bombardier (ALP-45DP) and are in use in USA and Canada and also by Talgo (Alvia S730) used by Renfe for hi-speed lines in Spain. It saves time in changing locos as well as cost of inventory.....When will we have such rolling-stocks....!!!!!