Good evening fyrbryr
Sure can. But first, just a word of warning. This type of preotection is a little on the weak side and can be removed in seconds (seriously, less than a minute) so don't trust it with your deepest darkest secrets, but it's OK to stop users from tinkering with formulae the shouldn't, or accidental erasure etc.
To do this from excel, just go to Tools > Protection > Protect Sheet and enter a password if you want.
A macro to do this is really simple, something like the below will suffice:
Sub Test()
ActiveSheet.Protect Password:="test"
End Sub
However, this will lock the currently active sheet, so it would be pointless to have a button on the sheet to lock it, you might be better off assigning it to a button on a toolbar.
HTH
DominicB