We're struggling with how to handle this. In fact, I remember well when my husband and I ran into the same situation with our son. At this age, kids are trying on all kinds of roles and acting out their fantasies and fears through play. This situation presents a rich opportunity for you to communicate important values to your child. Right now the reason will have to be very simple.
Guns hurt people.
But as your son gets older, you will be able to elaborate on the reasons, helping him understand why you don't like even pretend violence. When you deny him a toy gun, offer a more acceptable substitute by directing him toward something else that he finds exciting and fun. As for his gun play with the other children in the neighborhood, it is probably best not to interfere directly as long as no one is getting hurt. If you turn it into a power struggle, it may only make that kind of play more desirable. However, you could look for opportunities to introduce your son and the neighbor children to other activities that allow them to release all that energy.