I think at this point it'd be useful to note I saw it in french? With how unknown it is, to the point where I occasionally wonder if my mind didn't just make it up, perhaps this'll be an important detail....
It's an animated movie, starring an Asian teen as a main character, and that I saw around 2007-2013 if I'm not mistaken.
Anyways, it's very much like Mulan: an Asian girl (most likely Chinese, possibly Japanese), perhaps somewhere around 18, at least 16 I think, crossdresses in order to enter somewhere (in this case, a school, not the army). I believe it's also set somewhere around the same era as Mulan, and the artstyle is also similar.
The basic plot is the girl enters the school as a boy, befriends and subsequently falls in love with a guy, after circling each other for a bit there are interventions from the main villain which ends up with the guy dead, then the girls more or less flies off with his spirit at the end.
To be more specific, I remember quite a few scenes: one of the first of the movie feature all the boys within the academy, who have had to dress up as women, and someone notes that the disguised boy (let's call her Cha for simplicity's sake) looks very good as a girl, better than all her classmates. This makes a few eyebrows raise, especially the main villain's: he's a rich, ugly kid possibly the emperor or school director's kid (let's say Lau).
He's the first to guess Cha is really a girl, but needs confirmation, and impersonates her love interest (calling him Feng now) when she invites him to meet her near a lake at night to confess her gender. Cha is distraught at the fact Lau has found her out, but Feng somehow appears and she tells him too. At first he is hesitant, but after plunging his head in the lake and thinking a bit, he decides he loves her too.
I think that she ran away in shame right before that? I'm not sure, because the next chronological event that comes to my mind is Feng trapped outside of the school, with Cha inside, as they desperately try to get him in. But some of Lau's goons start beating up Feng: he holds Cha's hand through a high, round window as he dies. The scene ends with a shot from Feng's side of the wall, where you can only see Cha's hand wildly trying to grasp his, screaming his name over and over.
For some reason, this dooms Cha to marrying Lau. She prepares for the marriage, dressing up, putting on makeup, etc. She goes to Feng's grave, telling him about how she's going to get married and how she wishes he were there. Through the sheer power of love, his ghost appears, possibly making flowers bloom all about, takes her and flies back away to presumably heaven while Lau and his goons watch on helplessly.
I'm very iffy on a lot of the details here, so if you have a movies that matches even only half of the events or anything, please do tell me!