Did B-17 gunners beat on the wings of other planes in their formation?
That'd be a roughly 1 meter stick you've got to beat that other aircraft with, at most. Not a long stick at all.

By the time the other aircraft got that close a collision would be unavoidable. Not only would momentum carry them closer, but the banging would likely not even be heard by the crew of the other aircraft.

Remember they'd be wearing headphones, not just for the intercom but even more important for hearing protection. A B-17 is a LOUD aircraft when you're flying it.

Also, by the time you'd get that close the crews of both aircraft would have been screaming at their respective pilots for some time to ask them what the hell they're thinking getting that close to another aircraft.