In shulchan aruch (siman 2, saif 6) the author writes:
It is forbidden to walk in an erect posture.
Does this mean that good posture is forbidden or is the author referring to something else?
The Aruch Hashulchan Siman 2 Sif 9 addresses your issue directly. He says 'erect posture' doesn't mean that therefore one should walk hunchbacked, rather he shouldn't walk with his 'neck sticking out like a haughty person'.
And as I mentioned in my earlier comment, I recall reading somewhere that the 'measurement' for what is considered holding your head in a haughty manner is being able to see the ground in front of you, although I don't remember the source for that. If I find it later, I'll try to edit it in.