Network Rail has been fined £3.41 million over the death of a track worker.