Doing some research on the matter, I find the reports to be conflicting; However, it appears that turrets do not level up. Instead, they spawn at a particular level, randomly. Furthermore, it appears you can have Mk 1, Mk 3, Mk 5 and Mk 7 turrets.
Discussion and research in this Reddit thread suggests that each settlement has a "maximum level", in which the turrets will spawn. It is reported that this maximum level increases, the further you are from Vault 111. This is most likely the case, with an emphasis on how far you are to the south-east. The farther south-east you are, the harder the encountered enemies are. The harder the enemies are, the tougher your turrets need to be, to help push them back.
What I can confirm, which appears to be the best course of action in aiming for the best defense, is that you can still rig which turrets you build. As detailed in this Steam Guide, entitled "Get The Best Turret For Your Settlement", the turrets level generates randomly when you select it from the workshop menu.
As such, you can move between the Machinegun Turret and Heavy Machinegun Turret, and each time, the selected guns level will randomly generate. By rotating the turret to the left, you can see what number is written on its wing, before you build it. If it is not the highest desired level, simply move back and forth between your defense options, until the desired level spawns.