If you can’t sign the will, it can also be signed on your behalf, as long as you’re in the room and it is signed at your direction. However, you must have the mental capacity to make the will, otherwise the will is invalid. Any will signed on your behalf must contain a clause saying you understood the contents of the will before it was signed.
If you have a serious illness or a diagnosis of dementia, you can still make a will, but you need to have the mental capacity to make sure it is valid. Your solicitor should make sure of this, and you may need a medical practitioner’s statement at the time the will is signed, certifying that you understand what you are signing.