Yes, provided they meet these criteria.
If you are divorced, widowed or a previous marriage has been annulled, you will need the relevant documents to prove your current legal status.
And there is no residency requirement of any nature for a marriage to take place in Scotland.