Your logic should work with a tweak since Squad is likely a local or global variable, so your logic on the other ships should also be set squad to Squad, not set squad to sprite.squad. Another way of doing it since you are doing a function is determine the squad number before you call the function then send it through function as a parameter. Then every ship created in the function can be assigned param(0).
To actually calculate it there are a bunch of ways to do it. Easiest way is probably on enemy destroyed, take its squad number and then determine if any other enemies with that squad number exist. If no other enemies exist with that squad number then grant the bonus. But that's based on the gameplay and if enemies can die in other ways that do not grant the bonus or if they die off screen.