I use this piece of code to set the default selected option for my Select2, It also gets data via ajax:
var $element = $('#posttagform-tags').select2();
let data = JSON.parse($element.attr("data-selectedTags"));
for (var d = 0; d < data.length; d++) {
var item = data[d];
var option = new Option(item.text, item.id, true, true);
$element.append(option).trigger('change')
}
this code generates this HTML:
'<ul class="select2-selection__rendered"><span class="select2-selection__clear">×</span>
<li class="select2-selection__choice" title="ddd"><span class="select2-selection__choice__remove" role="presentation">×</span></li>
<li class="select2-selection__choice" title="pet"><span class="select2-selection__choice__remove" role="presentation">×</span></li>
<input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" aria-autocomplete="list" placeholder="" style="width: 0.75em;">
<li class="select2-search select2-search--inline"></li>
'
There isn`t any label inside each li tag, but li tag has title with the value that should be as the label of the option.