This took me a while to find out, so I'm answering my own question here for the benefit of others with the same need.
function main(workbook: ExcelScript.Workbook) {
let sheet = workbook.getWorksheet("Sheet1");
// will not let you lock/unlock cells if protected
sheet.getProtection().unprotect();
// just checking
let locked = sheet.getRange("B9").getFormat().getProtection().getLocked()
console.log('value of locked: ', locked)
// unlock
sheet.getRange("B9").getFormat().getProtection().setLocked(false)
// sanity check
locked = sheet.getRange("B9").getFormat().getProtection().getLocked()
console.log('locked value after set to false: ',locked)
sheet.getProtection().protect({
allowFormatCells: false
//allowFormatCells: true
});
}