Here is a way way to combine the output with a name/caption. I adapted this from the post-processing section in https://orgmode.org/manual/Results-of-Evaluation.html
(format "#+name: %s\n#+caption: %s\n%s" name caption data)
Here we have a block that outputs a latex string, for example.
"\\[\\int_0^2 e^x\\,dx\\]"
\[\int_0^2 e^x\,dx\]
Référence to 1