I had the same problem with a phone we just bought. I figured out what the problem was, so I am adding my solution hoping that it helps someone else.
The main issue is that the new phone that we bought came with an older iOS version (17.5.0) , not too old, just one minor version back. However, the phone that got replaced was running on the newer version of the iOS (17.5.1) and therefore the iCloud backup was based on the newer version. Even though the version difference was minimal, when we tried to restore the new phone from iCloud it would stay on the loading screen forever, never finishing - even after hours of waiting.
The solution was simple enough and logical. 4 steps:
1) First we started the new phone up without signing in at all and without doing an iCloud restore.
We treated the phone as if it was a completely new phone without any backup, and without signing in to iCloud. Yes, it is possible to do that during the setup process, just make you explore all the options.
2) When the setup was complete, we then updated the phone to the latest iOS version.
3) We then followed the instructions to reset the entire phone through "Settings >General > Transfer or Reset iPhone > Erase All Content and Settings".
4) We then set up the new phone by following the instructions and signing in to our iCloud account and picking to restore from the iCloud backup.
All worked fine then.