Yes bad posture can cause upper back pain as well as other back pain and spine problems.
When sitting at a desk you should always make sure to use the proper posture while sitting at your desk to avoid any back pain.
Never slouch in your chair or sit too far too the front of the chair.