How does energy conserve during superposition of wave? Let's consider two overlaping particles of mechanical wave, since it's a mechanical wave, we can think of it as spring-like so energy of particle $ E= \frac{1}{2} k A^2 $ where A is the amplitude of the particle.
Let y1 and y2 be displacement of two particles,
then energy of first particle $E_1 = \frac{1}{2}ky_1^2$
energy of second particle $E_2 = \frac{1}{2}ky_2^2$
total energy $E = E_1 + E_2$
according to superposition total displacement $y = y_1 + y_2$
so total energy $E = \frac{1}{2}ky^2$
$=  \frac{1}{2}k(y_1 + y_2)^2    $
$= \frac{1}{2}ky_1^2    +    \frac{1}{2}ky_2^2      + ky_1y_2   $
$E  =  E_1 + E_2 + ky_1y_2  $
So value of total energy is different so how does energy conserve?
 A: When two mechanical waves constructively interfere with each other, another pair of mechanical waves necessarily destructively interfere with each other, balancing the equation out. Link
You can imagine it as if one wave was to exert a force up, then an equal force is exerted downwards. (Newton 3)
A: The confusion arises from the fact that it is not two individual particles in a mechanical wave that is superpositioning, but rather the waves which they are a part of.
These waves constructively interfere in some places, and destructively in others, conserving energy.
A: Indeed, the energy of two waves is different from the sum of the energies that these waves would have, if they were excited separately. There is no paradox, since exciting the second wave while one is already excited may cost more energy, as the particles are already in motion.
To improve a bit on the example in the OP, let us consider actual waves (rather than a single oscillator):
$$
A_1(x,t)= a_1\cos(\kappa_1 x-\omega_1 t),A_2(x,t)= a_2\cos(\kappa_2 x-\omega_2 t),
$$
The energy density of the superposition will be
$$ w(x,t)=\left[A_1(x,t) + A_2(x,t)\right]^2=A_1^2(x,t) + A_2^2(x,t) + 2A_1(x,t)A_2(x,t) = w_1(x,t) + w_2(x,t) + 2A_1(x,t)A_2(x,t).
$$
Note however, that if we average on time as
$$
\overline{w(x,t)}=\lim_{T\rightarrow +\infty}\frac{1}{T}\int_0^T w(x,t)
dt $$
the cross-term will give zero contribution, and we will have
$$
\overline{w(x,t)}=\overline{w_1(x,t)}+\overline{w_2(x,t)}.
$$
