Way back when (and unfortuneately still today) people put a capped vertical stub of copper pipe near valves thinking that they would stop water hammer. Well, they work for a short while, but then fill up with water as the air is absorbed in the water. Basically, they are a short-term solution. The thing that does work is an engineered hammer arrestor. These either are a chamber with a bladder filled with air, or a piston with a seal and air on the other side. In either of those, the water never touches the trapped air, and those can work for years before they wear out. So, if you have water hammer rather than some other problem you've misdiagnosed what you are planning won't work for long.
But, if you want to drain the system to introduce some air to be trapped in those short pipe stubs, first, turn the water heater off. then, if it is drained, you won't ruin it. Don't turn it back on until you've turned the water back on then opened each faucet (hot and cold) so you get a full flow of water without air...then you can relight the water heater without fear that it is going to burn up because there is no water in it.