This paper investigates the optimal train motion control during the Virtual Coupling (VC) convoy formation where the following train (simply called the follower) needs to timely catch up with the velocity of the leading train (simply called the leader) while strictly adhering to the spacing principle that is undergoing change. We employ the Control Barrier Functions (CBFs) and Control Lyapunov Functions (CLFs) to demonstrate the control objectives within the formation progress, construct a safety control scheme composed of two controllers for the follower to achieve the coupling goals safely and apply the Quadratic Programming (QP) to efficiently compute the optimal constrained control input for the follower’s motion control. The effectiveness of the proposed control method is demonstrated through numerical simulations of different types of convoy formation cases.