<label for="variant_57139">12/#a8a3a0;</label>
<label for="variant_57139">12/<span class="color" style="background:#a8a3a0;"></span></label>
const regex = /#[a-f\d]+;$/i;
const replacement = '<span class="color" style="background: $&"></span>';
document.querySelectorAll('селектор сами сообразите').forEach(n => {
n.innerHTML = n.innerText.replace(regex, replacement);
});