The electronic speed governor plays an important role in diesel generator sets. The ideal method for developing and debugging the electronic governor is to simulate the diesel engine’s dynamic characteristics with the hardware-in-the-loop simulation system. In this system, the diesel engine can be replaced by a mathematical model. Our research proposed a novel diesel engine modeling method using the long short-term memory neural network for simulating dynamic characteristics of the rotational speed of diesel generator sets. The proposed model is trained and tested on the data of the real diesel generator sets. With different power loads and unloads, experimental results demonstrated that this method was able to successfully simulate the dynamic characteristics of diesel generator sets. In addition, comparing to other existing methods provided a conclusion that the performance of the model was better than others. Finally, the proposed model was deployed on an established hardware-in-the-loop simulation system. The results further demonstrated that this model was able to reproduce the diesel generator sets’ dynamic characteristics.