It seems like you have 2 separate goals that are sort of related. The first being to teach the child empathy and the other to de-clutter the house by getting rid of extra / broken toys. While these goals can be accomplished at the same time, that may not be the best approach.
The first problem I believe you could run into here is getting your child to really understand the idea of donating the toys. She is still pretty young and may have some trouble understanding the permanence of donating toys. I'm guessing that up until this point, the closest thing to donation she has encountered would be sharing. Sharing is a great way to be kind and learn empathy, but also has pretty low anxiety about losing what you are sharing (at least in terms of toys anyway). You share a toy, you get the toy back later (or, alternatively, giving someone else a turn means you will get your turn soon). But donation isn't like that. You give away a toy and you don't get it back. Ever. And that might be hard to swallow.
She might not want to give up any toys because she loves them. She also might not understand. And then you might find yourself with a screaming toddler who desperately wants Mr. Snugglekins (who got donated two months ago) to go to bed with her. This is also the time when she will most likely decide that nothing will distract her and nothing will make it better except Mr. Snugglekins and you had better find Mr. Snugglekins if anyone wants to get any sleep tonight.
Second, as other answers have mentioned, if you make it a hard and fast rule that she has to donate a toy before she can get a new one, you are setting yourself up for pain. First, she might perceive this as unfair, that you are forcing her to give up beloved toys. The flip side of this is that it also sets up the expectation that when she donates toys, she will (in her mind) get new ones. So then donating toys may not turn out to be an act of empathy, but rather a means of getting that new shiny toy.
But now the question is how do you teach the child empathy? Well, I would say to start small. Teach her to share. Model sharing yourself. Teach her to take turns. Point out when others are feeling sad and maybe suggest something she could do to help ("See Daddy over there. He looks sad, huh? Maybe you could give Daddy a hug and that would help him feel better.") Also, do service as a family and include her, even if it is in small ways. Go spend time delivering "meals on wheels" or a local equivalent. Go help grandma rake up all the leaves in her yard. Help the neighbor kid get his ball back that got tossed in your yard. There are many ways for her to help others and learn to care for them. Donating toys is one way, but consider other ways too.
Now, how to deal with too many toys cluttering the house? @aparente001's answer is an excellent suggestion on how to do that. Moving toys out of circulation and slowly introducing the idea of giving them away could help greatly with this. Just make sure your child does this because she wants to, not because you want her to or because she feels there is some reward attached to it.