It’s helpful if your dog knows sit, or at least has been reinforced for the position. But it’s not required.
Start at home, but eventually you’re going to practice everywhere greetings take place.
There are various ways you can use the treats in this exercise:
Your dog should be waiting calmly for you to greet him/her. This may take a few weeks, and the behavior may get worse before it gets better. But if you stick to the rules, your dog will discover that what pays is a calm greeting.