Hii Mohit,
Yes you can update the account owner, when firing trigger on the contact. Please take help from below code and modify it according to your requirement.
trigger updateAccountOwner on Contact (before update) {
Set<Id> relatedAccountId = new Set<Id>();
List<Account> updatedList = new List<Account>();
for(Contact con: trigger.new){
if(con.AccountId != Null){
relatedAccountId.add(con.AccountId);
}
}
for(Account acc: [Select Id, Name ,OwnerId from Account where id in : relatedAccountId]){
// Requested not use the hard coded Ids in the code. This was just done to let you show it can be done.
acc.OwnerId = ‘00528000000TxPV’;
updatedList.add(acc);
}
update updatedList;
}
Thanks.