An engineer deliberately ran a train off the tracks at high speed in an attempt to damage the USNS Mercy hospital ship, prosecutors say.