The relevant class (ExerelinSectorGen) is
hereFor each system, initial generation of the stars and planets, and pre-generation of the stations, is
hereOnce that's done, it assigns factions and markets to planets/stations
hereCurrently it just adds all inhabited planets/moons and stations in the sector to a List of habitable entities (planets and moons are in habitablePlanets, stations in standaloneStations). Then it shuffles each list and assigns the entities to each faction, sequentially, in a semi-randomized order (think Tetris). You'll probably want to change this so moons get the same faction (and maybe the same market) as their planets, and planets/stations in each system mostly belong to the same faction.
The logic and code to do this is left as an exercise to the reader
As for actually applying this: You could compile the modified version into your own ExerelinCore.jar and replace the mod's own one.
Or you could make your own mini-mod with the modified script in a new class (inheriting from the base ExerelinSectorGen), and have the mod be loaded after Nexerelin (mods load in alphabetical order). In your minimod's settings.json, set your new class to be the game's newGameCreationEntryPoint.
"plugins":{
"newGameCreationEntryPoint":"exerelin.world.MyExerelinSectorGen",
},