As LaTeX really creates copious amounts of temporary files anyway, you can't win anything here.
Also, outputting to stdout whilst suppressing the usual output to stdout would require changing things in the TeX core. That won't happen, so I'm afraid what you want is impossible.
I'm trying to create a shell script which converts latex-formulas to svgs.
For formulas only, there's relatively mature options that offer you a server that does that. Look into katex.org. The advantages would be speed and security (honestly, --write18
is probably disabled for you, anyway, but LaTeX is really not a piece of software I'd consider "safe for untrusted user input", not even "securable", without basically writing your own restricted TeX parser, which then as well might get a small rendering add on itself...).