WeBWorK 2.18 has been well-tested on Ubuntu 22.04. Things should probably work the same on Ubuntu 20.04, but you may run into some compatibility issues with older versions of packages.
If your server is a virtual machine then I recommend deploying a new VM running Ubuntu 22.04, installing a new instance of WeBWorK, and then copying your data from the old server. Once you have WeBWorK running on the new server you should be able to import the database from the old server (do a mysqldump, copy the dump file, then import it on the new server), and copy the courses directory from the old server to the new server. After upgrading the courses from the admin interface all of the courses should be migrated.
If you want to upgrade in place, instructions for upgrading to 2.18 can be found in the release notes. WeBWorK 2.16 should be recent enough that those directions can be followed directly. I highly recommend backing everything up before starting this process.