When in port, you can "buy" a fore mounting cannon if it's available and you have the "renown" to do so,
BUT
I would strongly suggest you "save" before such an upgrade because depending on fleetboat type, game version and activated modes you may end up with no cannon at all !!!
Anyway, aft guns are really handy when you're trying to escape on the surface. A sub would generally go into voluntary surface action under very "safe" circumstances (unarmed or seriously disabled/lightly armed targets). Under such circumstances the "akward" position of an aft gun is a secondary nuisance ...