:last-child is a CSS pseudo-class and therfore of no use outside a CSS style.
Additionally it dies not work in some email clients like Outlook.
I prefer a style tag over the inline setting of CSS.
Instead of replacement in the HTML string you can do this:

JsonTable
Convert the HTML table via xml() to a JSON object
json(xml(body('Create_HTML_table')))
JsonTableEnhanced
Manipulate the table object as needed.
Here: add a classname to table and to the last row in tbody
(Creating the “tr” array looks a bit wild, but you can also do this by initializing an array variable and appending to it in case you’re ready to add more boxes to the flow. 😉)
{
"table": {
"@@class": "table1",
"thead": @{outputs('JsonTable')['table/thead']},
"tbody": {
"tr": @{json(
concat(
'[',
slice(
string(take(outputs('JsonTable')['table/tbody/tr'], sub(length(outputs('JsonTable')['table/tbody/tr']), 1))),
1,
-1
),
',',
string(
addProperty(
last(outputs('JsonTable')['table/tbody/tr']),
'@class',
'lastrow'
)
),
']'
)
)}
}
}
}
HtmlTable
Add some styles and convert the object back to XML (HTML)
<style>
.table1 tr td {color: green;}
.table1 tr.lastrow td {color: red;}
</style>
@{xml(outputs('JsonTableEnhanced'))}
The table will look like this:
