If you are talking with friends and you see someone that you would like to add to the conversation you can address them with their name and you can ask them a question about the topic.
For example: You are standing with your friend Mike and John and your other friend Matt walks by. You, Mike, and John are discussing something and you want to know Matt's opinion. You can say, "Hey Matt! What team do you think will win the basketball game tonight?"
By asking a simple question and addressing the person you want to talk to, they can either give you a quick answer or they can walk over to you and join in on the conversation.
Other ways you can ask are:
"Hey, I was wondering if you would like to join our conversation."
"Could you come over to our table and talk with us?"
"Would you like to come over to our table and talk with us?"
"Are you busy? If not, would you like to join our discussion?"
"Hey, come here for a moment we would like to hear your ideas."
I hope these phrases are helpful to you. You can use them in informal & formal settings, but if you decide to use them formally, I would replace the "hey" with "hello" or "hi" depending on who you are talking to and your relation to them.