Yes.
That is the short answer. Suicide is always evil. If the protagonist’s best friend directly and deliberately kills himself simply to remove the demon, AND you portray this sympathetically, I think you may even cross into the of scandal, by portraying suicide as an acceptable answer.
However, I offer a gray area, such as the ending of the original The Exorcist. {spoiler!}
In the final scene, the lead exorcising priest orders the demon to occupy him instead of the victim girl. The demon then takes the priest’s body and propels it towards the girl, obviously intending to kill the girl. The priest, with his last bit of will power, throws himself towards the windows instead of the girl, where his momentum carries him through and he dies soon after hitting the ground, with the previously skeptical priest quickly performing the last rites.
In this case, the priest didn’t directly kill himself (at least in my interpretation of the movie), but merely took a protective evasive maneuver, knowing, but not intending, that he’d probably die, in a self sacrificing act to save the girl from the demon.
Obviously, some will disagree with this particular interpretation, but I found the movie largely sympathetic to authentic Catholic teaching, and offer it as an example of how you could create a tragic ending, without causing scandal or running afoul morally.