51B wing was not identical to the D wing at the wing root and elsewhere. The gun bays would not line up regardless I don't believe.
The wing structure of B was Exactly the same as the D save the LE extension and Root Chord. The P-51B/C positioned two 50's between landing gear and bomb rack. The P-51D/K had the same two 50's between bomb rack and gear plus one just outboard of the bomb rack.
Same airfoil, same span, same Mean Aero Chord, etc - no change required to mount the guns vertically instead of angled. The same wing that mounted 2xHispano II 20mm in the Mustang IA/P-51 went to A-36 (mod for bomb rack and replace 20mm w/50 cal), P-51A (same as A-36, but no dive brake), P-51B/C (same as A), P-51D/K (same as Mustang I, IA, P-51, A-36 and P-51A/B/C except for adding one more 50 cal and greater ammo capacity). Landing lights and pitot tube and aileron mods differed but airfoil, span, rib locations, spar location, flaps - remained the same. The new LE introduced a secondary spar as well as landing gear uplock and door changes but did not change the wing.