Q:

Antlr: can I rewrite tree differently if repeating a list or not

In my ANTLR grammar I have a rule that says a query can be a single fragment or a list of fragments joined together with the PLUS symbol. I'm generating an AST as output and what I'd like to be able to do is rewrite the node depending on the number of fragments. 
If there is one fragment, there should only be a single node. If there are multiple fragments I want the root node to be PLUS and all fragments as children. Is this possible? 
query
    : frag (PLUS frag)*  -> ^(PLUS frag*)
    ;

A:

Sure, you can use predicates inside rewrite rules like this:
p
 : M N? P? -> {boolean-expression-1}? ^(rewrite-rule-1)
           -> {boolean-expression-2}? ^(rewrite-rule-2)
           ->                         ^(rewrite-rule-3)
 ;

In your case, simply check for the presence of the PLUS token in your boolean expression:
query
 : frag (PLUS frag)* -> {$PLUS != null}? ^(PLUS frag+)
                     ->                  frag
 ;

frag
 : ID
 ;

ID
 : 'a'..'z'+
 ;

PLUS
 : '+'
 ;

(note that fragment is a reserved keyword in ANTLR)
Input like "a" would be parsed like this:

and "a+b+c+d" as:

I'm assuming you're not looking for a binary tree, right? If you are however, using the inline tree operator, ^, would make this as easy as this:
query
 : frag (PLUS^ frag)*
 ;

creating the following AST for "a+b+c+d":

