Switching weapons animation with mecanim?

Let’s assume I have character with two weapons. One weapon is on his back and the one he is using is on his hand. Then I press key and my character should switch weapons with animation. Also this animation should only affect his upper body so legs can keep running or standing or whatever they were doing.

The question is can I achieve this with mecanim?

This can be achieved by using avatar body mask.

At the end of this tutorial Unity 4.0 - Mecanim Animation Tutorial you will find out how to use body masks.

Just an additional note (since this is one of the first link that appear on Google when searching for Unity Humanoid weapon).

To make “stick” the weapons to the hand and to the back while using the humanoid animation type would be to expose the related bones to which you want the weapons be hold to.

For example, the hand that hold the weapon’s handle with the trigger should have its bone exposed (if you’re using the Optimized Game Object option for humanoids) this will allow the GameObject to have only the exposed bones shown in its children. (A lot more simple than searching through all the bones children to find the right one.) You could also expose the Torso related bone. That way, through a series of simple scripts steps you could animate the body and change the parenting of the weapons based on wherever you want the weapon to be hold.