It is simple, join the group, wait 5 people to enter the queue, join with the other group, wait for more 5 people to enter the queue, join with the other group.
Then you will have 4 parties from the same guild on the same team, versus a probably random team.
(More detailed, join the queue with first group, the queue goes to 10/40. When the queue reaches 15/40, join the second group, then it will raise to 20/40, wait till 25/40 to join with the next group. Repeat till 32/40.