Both would work...
If you're on site where English is the focus, everyone is going to be concerned about right or wrong...
If you're telling your friends about the results, nobody will care and either would pass unnoticed...
Both are fine. Your choice of preposition (in or on) might indicate a slight difference in how you (the speaker) perceive the experience of the exam but that's PERSONAL MEANING, and there is no right or wrong (in this case)
Sometimes in / on have different meanings -- not in this case.
If the exam was an accreditation exam where, for example, you are a pharmacist and you're doing role plays with patients and being graded on your English (this is how it's done in Canada)... where you're actually in a room, with people, doing stuff, being graded...then you might use "in the exam" because you were "in" an exam SITUATION.
If it's just a paper test, you might say "on the exam"
There is just a slight difference in nuance and tone, and it's personal.
Everyone would interpret it differently and none would be wrong.
Hope that helps.