The traditional leader-follower formation algorithm can realize the formation of multiply robotic fishes, but fails to consider the energy consumption during the formation. In this paper, the energy optimized leader-follower formation algorithm has been investigated to solve this problem. Considering that the acceleration of robotic fish is tightly linked to the motion state and energy consumption, we optimize the corresponding control parameters of the acceleration to reduce energy consumption during the formation via particle swarm algorithm. The whole process has been presented as follows: firstly we realize the formation on the base of the kinematic model with leader-follower formation algorithm; then the energy consumption on the base of dynamical model are derived; finally we seek the optimal control parameters based on the particle swarm optimization (PSO) algorithm. The dynamics simulation of the energy optimization scheme is conducted to verify the functionality of the proposed energy optimized leader-follower formation algorithm via MATLAB. The optimized results demonstrate that the proposed approach, reducing energy consumption during the formation, is superior to the traditional leader-follower formation algorithm and can reduce energy consumption during the formation. The novelty of the work is that we can reduce the energy consumption during the process of formation by considering the energy consumption, which is a gap in the current research field.