It is not difficult to get it right what pronoun we should choose if we remember one simple rule: if a pronoun goes after a linking verb, we use it in the subjective case, not the objective one.
Yes, the verb 'were' acts here as a linking verb because it links not the action but what the subject is: If I were he - there is no any action here.
Then, let's remember the basics:
|Subjective pronouns||Objective pronouns|
For example 👇
If I were he, I would go to the GYM regularly.
If I were she, I would study harder.