The changes you've suggested are already implemented in pgAdmin (https://github.com/postgres/pgadmin4/blob/master/web/pgAdmin4.py#L87). Almost all the servers provide the way to set the header - "X-Script-Name". pgAdmin uses X-Script-Name to set the prefix. You don't need to add any new config in pgAdmin. For instance, in nginx it can be done as:
I have added a commit on 2 files to include a base path that would avoid all the hassle while doing a reverse proxy on to the pgAdmin. Please find the commits below.