Current status: After HA Core 2023.4 it is still possible to swap entities AND keep the history of the old (replaced) entity.
According to How to replace entity in Energy Dashboard by new one without losing history - #2 by petro the process now with HA Core >= 2023.4 is:
1. Delete old entity
2. Rename new entity to old entity_id
3. New entity will inherit old entities history
Do not under any circumstances rename the old entity before you delete it, this will cause the history to follow the renamed name.
There’ll also be some errors logged to the HA log which seems to be “normal” for this kind of database and entity registry operation.
Another guide which seems to work fine according to Replacing device but keeping entity_id/long term statistics in HA - #12 by mekaneck can be found (via Replacing device but keeping entity_id/long term statistics in HA - #10 by mekaneck) at HA Energy Dashboard FAQ · GitHub
It seems way more complicated as it involves restarting HA, which shouldn’t be necessary (anymore with HA Core >= 2023.4).
For all further information I strongly recommend to look at this topic where few open questions should be answered shortly: