How to replace a 50 ohm speaker with 25 ohm speaker?
Yes, you can replace the 50Ω speaker with a 25Ω speaker and a 25Ω resistor in series. This will be at the cost of a bit of additional distortion and most certainly lower sound volume.

A bit of additional distortion because the impedance of the speaker is not exactly 25Ω over the entire range of frequencies, whereas the resistor will have a constant impedance, whatever the frequency. So it means that, depending on the frequency, the speaker will see a slightly varying RMS voltage across it.

Lower sound volume because, instead of 100% of the power provided by the amp being delivered to a speaker, we now have 50% transformed into heat and 50% delivered to the speaker. But this is not accounting for the speakers efficiency, which can greatly vary from one speaker model to another, so it could be compensated somewhat.

But I guess both of these matters are not really relevant in your case. Given the speaker power, it doesn't seem to be a hi-fi device (and if it's a toy, you'll certainly be happy it become quieter than before - I have myself added some series resistors on the speakers of a few of my son's toys).

Additional info: Why replacing a 50Ω speaker by a 25Ω speaker may cause some damage? Because the amp is built for a fixed gain and therefore fixed voltage level output. If you lower the speaker impedance, it will then have to deliver a higher current to feed the speaker (for the same voltage level - Ohm's law). So at some point, you may exceed its current rating. It is most likely not dangerous for the new speaker (provided it is rated appropriately), but can be dangerous for the amp in the device.

Not that if you choose a speaker with a higher impedance than the original one, you don't risk exceeding the amp ratings, so you're safe without resistor. But you're still subject to the lower volume drawback because the speaker will see less current through it.

Also, the power rating of the new speaker must be considered: in your case, you're safe because it is greater than the original one (0.3W vs 0.2W). And actually, because the new speaker will see half the power of the original one, you would be safe down to 0.1W.