Personally I would keep things simple and as easy to read as possible
String tempText = "text-warning";
if (temp == 127)
{
tempText = "text-error";
}
HTML += "<td class=\"text-right" + tempText + " °C</td>";
In practice I would probably not use a String at all