I have no idea if the following will work, but it's the next thing I would try in your place. I combines a couple of things that might work on their own, or not.
First I would go to Settings > iCloud and confirm that I am not signed in.
Next I would go to Settings > General > Reset > Reset Network Settings.
While that's going on I would restart my router. Yes, I know other things are working, but routers can cause problems on individual devices without affecting others. It's complicated.
When the router is back online, rejoin your home network, then go back into Settings > iCloud and see if you can sign into iCloud.
Another, unlikely, scenario is that you have a firewall, and for some reason it's blocking Apple's authentication servers. If you do, you can try turning off the firewall while signing up. Later you'll want to identify the necessary changes in the firewall.
The firewall would not affect the icloud.com site, since authentication would be indirect through the website.
Good luck.