Yes. If the spine is affected by osteoporosis, the vertebrae become fragile from a loss of bone density. This in turn causes each vertebra to become slightly shorter. The combined loss of height in the vertebrae can account for the decrease in a person's stature.
Another explanation is that the affected vertebrae can be compressed merely from the weight of the body or from minor trauma. This is called a compression fracture. Such a fracture can result in loss of height as well as the "humpback" appearance sometimes seen in those with osteoporosis.