it depends on the installation, but I would move
univention-app stop nextcloud to be the first step.
nano /var/lib/univention-appcenter/apps/nextcloud/conf/config/config.php is only copied to the container on an app-update and not every time the app starts. So to follow your path, you would have to change the
config.php inside the app too. You can do it, but I think it is in general not recommend with
univention-app shell nextcloud. Perhaps you will have to install an editor inside the container too.
Be careful when editing
nano /var/lib/univention-appcenter/apps/nextcloud/conf/config/config.php and change the permission back to the original owner, that is: www-data. Or on the next app-upgrade you will have problems on the initial setup.
The mentioned way by @ahrnke seems to be safer.