The first question to answer would be "what does x bar mean?". STACK tries to encourage meaning in mathematics.
If it has no meaning then you could just have students type in "bar(x)". Then define
texput(bar,lambda([ex],sconcat("\\bar{", tex1(first(ex)), "}")));
to display the "bar" function (which does nothing) with a bar over the argument.
Do you have "mean" in mind? Maxima has a "mean" function already. Is that what you want?
That's a little more complex, because Maxima's mean function expects a list. If you type mean(x) you will get an error. You could put the following in the question variable.
mean(ex):=texmean(ex);
texput(texmean,lambda([ex],sconcat("\\bar{", tex1(first(ex)), "}")));
but then you won't have the "mean" function available elsewhere in the question!
Chris