JSFiddle - React, Tailwind, and code Playground

HTML

<select id="selectbox">
    <optgroup label="optGroup1" id="optGroup1">
        <option>aaaa</option>
    </optgroup>
</select>

JavaScript

var optgroup1 = document.getElementById("optGroup1");
    option = document.createElement( 'option' );
    option.value = option.text = "test";
    optgroup1.parentNode.insertBefore(option, optgroup1.nextSibling)