There's no such thing as a "root" password on Ubuntu systems. Perhaps you are confused. Ubuntu uses sudo and sudo is network aware, to it needs to compare the current hostname with whatever is inside any of the sudoers files.
The only solution for a bad sudoers setup that I know, and it will only work if full drive encryption isn't being used, is to get into rescue mode or boot from alternate boot media, then fix the issue inside the sudoer's.
BTW, hostnames are case insensitive, but some old scripts may not be written to deal with it, so a hostname really needs to be all lower-case. Same for usernames (all lowercase, numbers ok, if not the first character, no special characters at all).
You can use the same ISO you used to install any desktop Ubuntu version in "Try Ubuntu" mode to edit the sudoers on the storage device inside the computer. You'll need to mount it and traverse down that mount into the /mnt/etc/sudoers file or sudoers.d/ directory to make the fixes.
In general, the first user added to an Ubuntu system gets placed into the sudo group and that is normally sufficient to gain sudoer access. For example,
Code:
$ egrep sudo /etc/group
sudo:x:27:thefu
Obviously, the username on hour system will be different than mine.
Part of being a good admin is avoiding issues before they happen. That's mostly what this post is about. There are lots of things that should, but need special processing for them to work. Best to avoid those situations.