Indeed, «сдать экзамен» has two meanings in Russian: ‘take the exam’ and ‘pass the exam’.
So you can use this verb alone for all cases:

I took the exam. I hoped that I would pass but I failed.
Я сдава́л экза́мен. Ду́мал, что сдам, но не сдал.
(impf. past) (perf. fut.) (neg. perf. past)
Here, the verb aspect makes the difference.

Мата́н я не сдал. (perf.) ‘I failed the calculus exam’
Мата́н я не сдава́л. (impf.) ‘I didn’t take the calculus exam’

However, the verb aspect in Russian is a complex thing. In some cases you cannot use a certain aspect. For example, when you describe multiple events, you need the imperfect, and the meaning becomes less clear:

сдава́л экза́мен пять раз и ка́ждый раз не сдава́л.
I took the exam five times and each time I failed.

A sentence like this can be said but doesn’t sound good.

To be more unambiguous, one can also use:

у меня́ был экза́мен ‘I took an/the exam’
я успе́шно сдал экза́мен ‘I passed an/the exam’
я завали́л экза́мен ‘I failed an/the exam’

Я ходи́л на экза́мен пять раз и ка́ждый раз зава́ливал.
I took the exam five times and each time I failed.