What you are referring to is called a "Coal Torpedo", the first documented use of which was made at least as early as the American Civil War 1861-65. Essentially it's an iron tube, packed to the brim with black powder and painted black so it blends in with a mass of coal. Which was deposited in a coal bunker or coal storage bin, and hopefully eventually shovelled into a ship or train engine's fire box. The results could be fairly destructive, in one instance during the ACW, the Union logistical base at City Point, Virginia was devastated by a single coal torpedo which detonated in an ammunition barge, the resulting explosion killed approximately 43 people and injured a further 126. The Austro-Hungarian military/intelligence agents also used coal torpedoes of a more modern sort against the Italian Royal Navy with some success during WW1, one of which may have been responsible for the destruction of an italian dreadnought, the Leonardo da Vinci.
One way I can think of tampering with a train engine, which won't necessarily destroy the train, although it will play havoc with the engine itself is contaminated the boiler water, which on most ships and trains was usually cleaned or distilled at least from the 1880s onwards. For instance, adding salt to clean boiler water will cause it to foam dangerously when heated, it also prevents the engine from reaching full atmospheric pressures. While you can run a boiler with salt-water at low power, it has to blow off steam at least several times each hour to prevent dangerous build ups of heat and erratic pressures.