Distributed Endogenous Internal Model for Modal Consensus and Formation Control