Children this age will do about anything that leads to attention and reaction. Your toddler knows that if she does this her friend will cry, thus getting a reaction from her.....and then attention from you when you sit down and talk to her.
The key is to take that reaction, and attention away. The next time her friend comes over sit down with your daughter and remind her to be nice to her friend. If and when the NO starts, immediately intervene and remove your child from the picture. A time out should be used. One minute per year of age is appropriate. Once this is over remind your daughter again this behavior is NOT appropriate and allow her to return to her friend. Should it happen again then the friend should go home you should sit her down and again remind her if she can not play nice then she can not have her friend over.
Do not allow the yelling to continue until the other child cries, otherwise she is still getting the reaction she is seeking. Intervene immediately and stop the yelling. It may take a few times of sending her friend home before she learns this behavior results in her losing her "play date" but she will put it together and learn better behavior.
Anytime your child displays inappropriate behavior, there should be a immediate removal from the situation so she learns. It sounds like she is learning how to create reactions and this may get worse before it gets better. Additionally children move on to hitting, biting and hurtful comments if this is not corrected quickly so the sooner you nail down that this is not acceptable she will learn what is and you will have avoided a even larger problem down the road.