Powering 5W generator with A23
Will it burn or will it last for long?

Probably neither, look at the Wikipedia page on the 12 V A23 battery.
Note how this battery consists of many small coin cells in series.

Coin cells cannot deliver much current, they're quite small.

5 W at 12 V that's 12 / 5 = 416 mA, that's too much for almost any coin cell.

Scroll down on the Wikipedia page, under the external links there is a link to an Energizer A23 battery. Note how the Capacity is shown for discharge currents of 2 to 15 mA. Hmm, that's around 30 times less current than what you would need for 5 W.

There's also a thing called internal resistance. This internal resistance is related to the size of a battery, small batteries have high internal resistance and that means they cannot deliver a high current.

Conclusion: A23 batteries simply aren't suitable to deliver 5 W. You should use eight AA cells in series instead, they can easily manage 416 mA.