I'm pretty sure this isn't a mechanic already, but I think it would make sense that the longer your faction controls the town the more your rep in that town increases (until positive).
As it stands, the process for taking control of a town results in the towns folk taking a lot of collateral damage. Meaning one NPC gets shot, then the guards agro, then you've got to wipe the whole town because it attacks you.
This results in massive losses in rep. This could be fixed by gradually increasing rep for the faction members that hold the town (until positive rep is obtained). Maybe you could get a rep bonus with every militia that gets added.
If you are trying to take the town, kill a bunch of NPCs, then fail to take the town. Well then that's just you causing trouble in the town and you deserve the negative rep for it.
If this is already a mechanic, then I am sorry for wasting your time.