Proceed at your own risk (and joy).
macOS 12.6 Monterey
Signed out of an iCloud account. Attempting to sign in to another iCloud account (or even the original iCloud account) failed silently and repeatedly, even after rebooting. Creating a new macOS user account and signing in to iCloud therein worked as expected, but the prospect of manually migrating over user data and settings (while not borking the now-functional iCloud sync) was not especially congenial.
The ability to sign in to iCloud under the original macOS user account was restored thanks to nikhilgohil11's suggestion from 2019:
The urtext for this answer appears to be from 2015 by Kurt Lang, who credits Apple support. richard2's 2016 post mentions signing out of iMessage and FaceTime as well as disassociating the Apple ID from your macOS user account (if they were previously linked) beforehand.
Tried defaults delete MobileMeAccounts
and rebooting as suggested in several places to no avail.
Combining defaults delete MobileMeAccounts
with deleting/moving the sqlite databases in ~/Library/Accounts/ like so:
sudo -v ; killall -9 accountsd com.apple.iCloudHelper ; defaults delete MobileMeAccounts ; mkdir ~/Library/Accounts/Backup ; mv ~/Library/Accounts/*.sqlite* ~/Library/Accounts/Backup/ ; killall -9 accountsd com.apple.iCloudHelper ; sudo reboot
went untested; this report did not inspire confidence.
Deleting ~/Library/Preferences/MobileMeAccounts.plist and the contents of ~/Library/Accounts/ sounded infelicitous, given that it "will cause every account you have setup in the Internet Accounts System Preferences pane to be deleted".
Fix Can’t Sign into Apple ID on Mac Ventura, Monterey M1 & Intel
What to Do If You Can’t Sign In to iCloud After Updating Your Mac
Copy entire user profile to new device with different username
macprefs: Backup and Restore your Mac System and App Preferences (e.g. defaults write)
/mac | Oct 08, 2022