Yes, you are allowed to do so. However, only certain visas allow that.
If you hold any other visa, you can still apply. However, you have to leave the UK and start the process from outside the UK using the regular channels.