I have an HTML like this:
You want to store/send the selected values in one array, right? So why you use unique names then for each checkbox?! ... if they belong together then name them appropriately like so:
//....
Then they will be sent as an array on submit automatically, no further rearrangement needed ... or if you really want to do it the ajax way still, you can easily get all the ids for the category-checkboxes like so:
$('[name="pgggo-category-sep[]"]').on('change', function () {
let values = Array.from($('[name="pgggo-category-sep[]"]:checked'))
.map(elem => $(elem).val())
})