You can try this Formula:
=QUERY(A2:B7, "SELECT A, SUM(B) GROUP BY A LABEL SUM(B) '" & C1 & "'")
Changing the value in C1 instantly updates the column label in the result.
C1
Sample Output: