It is possible to "lock" focus simply by accessing the Custom Functions - named CF. Use the following CF menu:
CF-10 - set to 2. Then the release button will only release.
CF-12 - set to 1. Now the AFL button will handle the AF operation.
The camera must be set in AF-mode on the lens and the AF selector in C or S mode on the camerabody. Now the AF motor will stay fixed and cannot turn and thereby change focus. This will prevent the lens from getting out of focus when mounted vertically with the camera.
This way you have now programmed the AFL button to take care of focus. If you prefer to have the AF function transferred to the AEL button - this can be done using CF-9 - AEL and AFL button switched.