Upgrade ubuntu to a specific release

To answer your question, I don’t think Ubuntu officially supports upgrades to releases other than either the latest release or the latest LTS. It might be possible to upgrade to a specific release by changing the appropriate code name in /etc/apt/sources.list and running apt update && apt dist-upgrade, but that won’t take into account any upgrade step performed by the do-release-upgrade tool (if any).

However in your specific case, 17.04 isn’t an LTS, and is already out of support. 16.04 is still supported; if you don’t want to upgrade to 18.04 you should stick with 16.04.