In this paper, we provide an in-depth discussion of the problem of predefined-time formation control for Multi-Agent Systems (MAS) and consider the presence of non-periodic Denial of Service (DoS) attacks. The suggested approach utilizes the system state to achieve time-varying formation of MAS within predefined-time. It effectively mitigates external disturbance or non-periodic DoS attacks. The algorithm combines the predefined-time Lyapunov stability theory with the Terminal Sliding Mode Control (TSMC) is the strategy of predefined-time sliding mode control. It creates a new distributed sliding mode surface to ensure the speed and stability of multi-agent formation under dynamic change and uncertainty conditions. The range of the system convergence time is specifically linked to the changeable parameters, which simplifies the design of the control algorithm to satisfy the appropriate requirements for convergence time. This study demonstrates the stability of the method through theoretical analysis and validates its effectiveness by conducting simulations on the Matlab experimental platform. The simulation results demonstrate that the anticipated limit of the time required for the algorithm to achieve a stable formation is less cautious and more resilient compared to the current TSMC algorithm.