Replace string in file without temp file

I have a multi-gigabyte text file and I want to replace all occurrences of a string in it with something else.

Usually, I’d use sed -i for this as suggested here: find and replace a string in a file without using temp file with SED

However, this creates a temp file under the hood and I need this replacement to occur in an environment that won’t have the disk space to support that.

How can I modify the file in-place?