If the force constant of a wire is k, the work done in increasing the length L of the wire by l is
Comparing F=YALl with F=kl we have k=YAL, which is the spring constant of the wire.
Since we are comparing with a spring, the energy stored is U=12kl2