Any of these should work,

<div style="width: min-content; margin-left:auto;">

$\TeX$

</div>

or

<span style="float: right;">

$\TeX$

</span>

or

<div style="text-align: right;">

$\TeX$

</div>

There might also be a KaTeX operator for it: See Supported Functions · KaTeX for a general list of supported functions.