You can try the code below. You'll have to specify the protection options in the protect json object. You can bring up the options available to you by using ctrl + space within the object. The options will tell you what value they expect. Here's an example of the code using protection selection mode. It expects an enum value of which the options are none, normal, and unlocked:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
if (selectedSheet.getProtection().getProtected() === false) {
selectedSheet.getProtection().protect({selectionMode:ExcelScript.ProtectionSelectionMode.none}, "MDM258!")
}
}
You may have to play around with the options and find an option which works for you.