Hi,
I'm not sure you can, well not without creating a script to do so. Even then, it's a bit risky.
Really, you shouldn't allow them to edit .env files directly, instead, provide a config and allow them to specify values there.
If it's crucial those changes must be done inside of the app via a form, then you can create a database table with fields for each aspect you wish to change and load those into the config at runtime.
That said - if you are eager to allow that functionality and let them edit the .env file, you could load the .env file into a textbox on an authenticated page, and when you save it, save it over .env file. Basic file input/output can handle this. Make sure the server user (nginx/apache/etc) has permissions to edit the file.
Let me know if you need me to clarify some more.