TL;DR:
Hold the Zammad package, upgrade your distribution, migrate PostgreSQL, unhold your Zammad package and upgrade Zammad based on the current distribution.
Longer version:
This might differ on source code installations where you basically wanna take the same steps, but:
You’ll have to “re run” the installation part on the new OS version to have correct rubies installed and stuff. This might be a lot more difficult than with a package installation. If you feel unsafe with these steps, you may want to prefer using a backup and restore based migration.
See: Backup and Restore — Zammad System Documentation documentation