You could use dynamic routing with an Asterisk query to achieve this.
Dynamic Routes Module - PBX GUI - Sangoma Documentation (atlassian.net)
You could adapt something like this, you just need to determine the correct variable.
Checking Queue Caller Count with Dynamic Routes - FreePBX / Tips and Tricks - FreePBX Community Forums