It might be the cartridge in the tub/shower valve. We are dealing with an issue on a apartment project right now with water hammer in many of the tub/shower valves. Usually, pipes that aren't secured properly only rattle as the valve is turned on or off. You might try adding shock arrestors under the lavatory on the water lines. Or just replacing the cartridge might solve the problem.
I agree with installing water shock arrestors. Tubs and washing machine supply lines are the two fixtures that are directly connected to the main feed line with 1/2" piping and not reduced to 3/8". If the main feed for the house is run in 1/2"pipe, the high volume of water causes the pipes to move.
The problem with that type of shock arrestor is that eventually all of the air in the 6" piece of pipe will be absorbed into the water, and it will no longer work. A factory produced shock arrestor has a physical barrier between the gas on top of the piston and the water underneath, and will do it's job for a much longer period of time.
I agree with Mr. David. A loose washer will make a loud vibrating sound. What kind of shower valve do you have, if it's 2 or 3 handle then I would check all of the flat washers on them.
Hammer arrestor are like shock absorbers and are mainly helpful to absorb the shock of a valve closing such as a single handle faucet, or a solenoid control valve in a washing machine, Irrigation valve or ice maker. They don't always solve the problem.
Some shower valves have integral stops (built in shut off valves) which allow you to shut off water to the fixture only. That is if they work.