Edit text file in a folder owned by a different user on macOS? I have system admin password
If you know the path to the file that you want to edit, you can use:

sudo -e /path/to/file/name/here.txt

and it will allow you to edit it with your $EDITOR of choice.

If you want to use the Open dialog box, you might think this will work:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit

But that fails with an error:

"Illegal instruction: 4"

However, BBEdit will work:

sudo /Applications/BBEdit.app/Contents/MacOS/BBEdit

And you can use BBEdit for free.

Oh, and both methods keep the original ownership of the file and permissions intact.