I think you would need to pass the union call as an argument to a subselect which Guidewire says is not allowed:
Note: You cannot use the union method on query objects passed as arguments to the subselect method.
This might be one of those fun instances that does not have a way to accomplish strictly using a query API call. It certainly would not be as efficient, but you could do both queries and then determine if 2 or more results were returned in gosu code since you are coding it in gosu anyway.
What do you use the results for? Is this a query that you run, get the results, and then take some other action outside of PC? If optimal performance is not important, I would just write this with a combination of query API calls and gosu code and not worry about recreating this SQL query exactly using a query API call.