First, create a part. Size it to 1,1,1, and position it on either the left or right side of your door. This will act as a hinge.
Next, use the Motor6D plugin. Duplicate your hinge part, and name it B. Name the other part to A. With the motor6D creator, select your door as the part to rotate, A for the motor, and B for the pivot point. This creates a motor6D.
Weld any parts part of your door to the part you selected on the first step of the plugin, and then weld A and B to your train. Turn off collisions and transparency on both A and B.
For scripting, you will have to edit the C0 property of the motor. An example is like shown: