There are some library methods and hooks, exported by world server, which could be used in lua scripts to manipulate party creation and party state itself.
You can search examples of usage in lua scripts and then implement what you exactly need
Exported methods:
{"LetRoleLeaveTeam"...