There are several factors to be considered to determine whether or not Harry Potter would be liable to prosecution under the witchcraft clause.
- Is he Jewish?
Regarding his Jewishness, as noted the evidence suggests he is Christian, although this does not preclude him from theoretically being descended from Jews (especially given Rowling's statement that Jewish wizards attend Hogwarts), so as per the OP’s request, both possibilities will be taken into account, beginning with the assumption that he is a non-Jew.
- Are non-Jews forbidden from performing witchcraft?
According to Rabbi Shimon (Sanhedrin 56b) they are forbidden, but according to those Tannaim who only include 7 mitzvot for bnei noach, they are permitted to perform witchcraft. (cf. Meiri there).
Rambam does not mention a prohibition for non-Jews to perform witchcraft implying that that they are permitted. This is also the implication of Ramban (Responsa attributed to Rashba: 283 cited in Bet Yosef YD 179) and the ruling R. Natan Geshtetner (Le - Horot Natan, VI:78).
Raavad, however, implies that non-Jews are barred from performing witchcraft. (Strictures to Hilchot Avodah Zara 11:4).
Accordingly, it is unclear whether even if Harry is a non-Jew he would be permitted to perform sorcery under normal circumstances.
- Which activities are considered witchcraft?
A wide range of activities are generally forbidden and many of them are performed by Harry. These include communing with the dead (cf. SHM negative mitzvah #38)[note 1] which Harry perform in book VII (in invoking his dead relatives by dint of a magic ring). And recitation of magic spells (ibid 35) which Harry does on a regular basis. And magic in general (ibid 34). And acting on the basis of predictions (ibid 32), which Harry does by taking the prophecy from book V into account. [note 2]
Accordingly, his general activities would be forbidden to a Jew. Even if he were a non-Jew, according to the view that they too are proscribed from performing magic presumably his activities would qualify (as I have not found evidence that the parameters would be different).
- Is there room for exceptions?
There is a remaining consideration. As the OP stated “These students, including the eponymous hero Harry Potter, must cultivate their magical abilities in order to defeat the evil wizard [yemach shemo]”
Harry repeatedly saves his life, and the lives of others from certain death, using magic. Prohibitions are generally waived when danger is present, so seemingly, it ought to be permitted.
However, Radvaz writes that one may not perform magic even to save a life, as it is conceptually related to idolatry (Responsa I:485, cf. Chinuch 512).
However, this does not seem to be a universal view, as the Tosafot hold that it is obviously permissible in order to save a life (Karetot 3b). Some infer this from Rambam as well [note 3].
Thus if he is Jewish, it would be permitted by dint of danger to life. If he is not Jewish, (then even if there is a general prohibition of sorcery), it is even likelier that it would be permitted, as in the event of danger to life as even idolatry is permissible for non-Jews, if the alternative is death, according to one view. (Cf. II Kings 5:18, and Sanhedrin 74-5).
Additionally, Maharshal (Responsa: 3 and Yam Shel Shelomo Chullin 8:13) cites an influential responsm of Rabbenu Menachem Katz that it is permissible to study and practice magic for the purpose of counteracting other magicians. This includes cases where lives are not threatened. . This is in turn cited by many authorities including the Bach (YD 179), Derisha, B'er Sheva (Sanhedrin 91a), and Tzitz ELiezer (IV: 17: Kuntres Refua B'Shabbat ch. 3).
Maharshal's wording (in Yam Shel Shelomo) is:
ומ"מ לפעמים יראה להתיר אפי' דברים שאין בו סכנת נפש, אלא סכנת אבר ... כי לא אסרה תורה אלא לשאול בהן ולרדוף אחריהן, ולהאמין בהם, שיש ממש בעניניהם, וראייה קצת לדבר, שהסנהדרין היו לומדים כישוף (סנהדרין י"ז ע"א) כדי לבטל כישוף של המחוייבים מיתה, וכה"ג מצאתי בתשו' מהר"ר מנחם מ"צ ...ומצאתי לו און מהאי סוגיא דלעיל, דאמרה איהי מילתא ואסרתא לארבא, אמרו אינהו מילתא ושריוה, אלמא דשרי לבטל כישוף, אעפ"י שלא היה שם שום סכנה, וכ"ש ע"י גוי דשרי
Accordingly, all study and practice of defense against the dark arts would be permissible.
- Execution of Execution:
Lastly, it should be noted that the Chinuch (62) writes that witches are only killed in Israel, so even if Harry would be liable he would not be killed. However, this would presumably only apply if he is Jewish, since non-Jewish courts can impose punishments anywhere, and the prohibition still seems to apply (cf. Chinuch 511).
In summary: Harry would most likely not be prosecuted under the witchcraft clause, as there are many reasons why his activities would be permitted. He is almost certainly not Jewish, and therefore probably not forbidden to practice witchcraft. Many of his activities (although by no means all) are necessary to save lives. Even those which are not necessary to save lives, most of his acts are devoted directly or indirectly to defeat of the dark arts of yemach shemo and others, which would also possibly be permitted.
[note 1] Although Rambam believes that there’s no such thing as magic, successful magic would seem to remain forbidden in some or all cases. More significantly, were he to realize that magic is real, he would presumably revise his opinion, and conclude that actual magic is prohibited. Additionally, many Talmudic opinions, and later authorities assume that the prohibition against witchcraft refers to actual magic.
[note 2] Although it is possible that this only includes astrological predictions, it seems to include all predictions.
[note 3] See Assiah 75-6 5765 pp. 7-32.