No, the mechanical energy does not change if it is ideal.
We define mechanical energy as the sum of kinetic energy and potential energy
ME = PE + KE
When the pendulum swings, potential energy is converted to kinetic energy and vise versa. But the sum of both remains constant, which is the mechanical energy.