One way is through a shared goal. Let's say there is a rebel cell that has been causing a lot of trouble for the Empire. The female stormtrooper and Darth Vader are both assigned to deal with it. During the mission, they face many challenges together. The stormtrooper shows her resourcefulness, and Vader starts to trust her more. He might share some of his thoughts about the Empire's future with her, and she starts to idolize him. This could lead to a relationship where she is not just a subordinate but someone he values for her insights and abilities.
In fanfiction, their relationship could develop from a chance encounter. The female stormtrooper could be in the wrong place at the wrong time and witness something she shouldn't. Instead of killing her, Darth Vader decides to keep her close to monitor her. As time passes, she begins to understand his motives and his power. She starts to assist him in small ways, like gathering intelligence. Gradually, Vader realizes she can be a useful asset and their relationship evolves from one of suspicion to a more collaborative and perhaps even a mentorship - like relationship where he imparts his knowledge of the dark side to her.
The relationship could start with the female stormtrooper showing great combat skills that catch Darth Vader's attention. He then begins to give her more difficult tasks, and in the process, they develop a mutual respect. For example, she could be the only one in her unit to survive an ambush, and Vader sees her determination.