Use the standard citation format employed in the course for open-book exams, whether MLA, APA or another style.
Don't worry about precise citation formats for most closed-book exams. Professors will not expect you to use full MLA or APA format citations during in-class exams. Instead, use simplified parenthetical citations of the author and title of the relevant source. For example, in a blue book exam you might write: "Rhetoric is a counterpart of dialectic." (Aristotle, "Rhetoric").
Use the correct format recommended in the 19th edition of "The Bluebook: A Uniform System of Citation" for legal writing or exams that test your specific ability to follow standards of law review citations. This reference manual ensures uniformity and clarity when making legal arguments. It is available spiral-bound and as an online subscription.