"Sorry" can always replace "excuse me" to give the same meaning in the same situations:
- When asking for permission:
"Sorry ,do you mind me using your pen".
"Excuse me ,do you mind me using your pen".
- When you ask for further explanation due to misunderstanding or not hearing well:
" Sorry , could you repeat that again"
"Excuse me ,could you repeat that again".
On the other hand "excuse me" can't replace "sorry" when one is apologizing for something wrong they have said or done:
" Sorry , I didn't mean to hurt you"
Here you can not replace it by "excuse me" : " Excuse me , I didn't mean to hurt you".