You can use Class Protection: https://developers.google.com/apps-script/reference/spreadsheet/protection
Adapted from above link you can try:
function pro(){
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription('Sample protected sheet');
// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script will throw an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
//YOUR CODE TO RUN
SpreadsheetApp.flush();
protection.remove();
}
EDIT
This worked for me:
function onEdit(){
//Adapted from: https://developers.google.com/apps-script/reference/spreadsheet/protection
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var me = Session.getActiveUser().getEmail();
if (me != 'owner email'){
var protection = sheet.protect().setDescription('Sample protected sheet');
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
//YOUR CODE TO RUN
SpreadsheetApp.flush();
protection.remove();
}
}