This will not be relevant to everyone but I am sharing in case it helps someone else overcome the difficulties I experienced.
If you look at the Asynchronous task list and select the upgrade job it looked like this (effectively a list of services starting and restarting continuously due to errors with the publishing tools service, then it eventually fails):
Upgrade step 2 of 2 : Started.
Upgrade step 2 of 2 : License check started.
Checking and validating server licenses.
Upgrade step 2 of 2 : License check completed.
Upgrade step 2 of 2 : Configuring application server.
Starting server on machine '{SERVERDOMAIN}'.
Upgrade step 2 of 2 : Configured application server.
Upgrade step 2 of 2 : Configured platform services.
Upgrade step 2 of 2 : Updating auto-deployed services.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Starting the service 'CachingControllers' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsManagement' on machine '{SERVERDOMAIN}'.
Stopping the service 'GeoAnalyticsTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'ReportingTools' on machine '{SERVERDOMAIN}'.
Stopping the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Starting the service 'PublishingTools' on machine '{SERVERDOMAIN}'.
Upgrade step 2 of 2 : Failed. Refresh auto-deployed services during upgrade
I tried a number of obvious things including restarting the services and restarting the server to no avail. After some online research I got to the root cause of the error with troubleshooting advice from foreign language forums. The upgrade only works with IE9 or newer installed on the host machine.
We were running Windows Server 2008 Standard SP2 (so not Server 2008 R2) and its default browser was IE7. Apparently the upgrade process for ArcGIS Server 10.5.1 uses the browser on the host machine to run upgrade scripts even if it doesn't tell you as much in the error messages.
We tested the fact the IE9 and up browser has to be installed on the host machine by the fact we tried to launch the upgrade through IE11 on a remote machine and the task still failed. However, after installing IE9 on Windows Server 2008 Standard SP2 the upgrade completed successfully.
I might add for anyone using Windows Server 2008 Standard SP2 that upgrading to a supported browser is no easy job either. Firefox and Chrome no longer support the OS so these are no goes as its not worth the risk using a non-vendor supplied legacy version. IE9 is effectively your only choice and this has three pre-requisite patches that need to be installed first before the IE9 upgrade file will run: KB948465 (Service Pack 2 if you've not yet installed this) then KB971512 then KB2117917.
Happy to tackle any questions for someone with a similar issue.