A good overview of what the B-plane is and how it's defined is available from the FreeFlyer guide.
The "B" in B-plane is the hyperbolic impact parameter, the semi-minor axis of the hyperbola that is the spacecraft's orbit. Importantly, as the equations from Wikipedia show, the impact parameter alone is not enough to determine the periapsis of the orbit. The other parameter required in the hyperbolic excess velocity, $v_{\infty}$, which is also the square root of the characteristic energy, $C3$.
You can think of the impact parameter as "the distance by which a body, if it continued on an unperturbed path, would miss the central body at its closest approach." (Wikipedia)
Unperturbed meaning we ignore the planet's (Mars) gravity in the B-plane representation. Mars' gravity will pull the spacecraft closer and therefore the close approach distance, $r_p$, is always less than the impact parameter, $b$, value.
Wikipedia gives a neat equation relating $r_p$ and $b$:
$$r_p=\frac{\mu}{v_{\infty}^2} \cdot (\sqrt{1+(\frac{b \cdot v_{\infty}^2}{\mu})^2}-1)$$
Which could be rearranged for $b$:
$$b=\frac{\mu}{v_{\infty}^2} \cdot \sqrt{(1+\frac{r_p \cdot v_{\infty}^2}{\mu})^2-1}$$
In GMAT I started with a Mars relative state vector for Mars 2020 from HORIZONS on February 1st:
JDUT , Calendar Date (UT ), X, Y, Z, VX, VY, VZ,
**************************************************************************************************************************************************************************************************
$$SOE
2459246.500000000, A.D. 2021-Feb-01 00:00:00.0000, -3.270678971433882E+06, -1.333631118481763E+06, 1.800947903043214E+06, 2.089538719640068E+00, 8.723492698345683E-01, -1.146618806007647E+00,
$$EOE
**************************************************************************************************************************************************************************************************
I'll assume you can create the necessary GMAT components (spacecraft, propagators, coordinate frames, etc.) and just give you the mission sequence code:
%----------------------------------------
%---------- Arrays, Variables, Strings
%----------------------------------------
Create Variable C3 mu rp B dV angle BT BR;
GMAT mu = 42828.37; % GM for Mars
GMAT rp = 3389.5; % Mars target periapsis (km)
%----------------------------------------
%---------- Mission Sequence
%----------------------------------------
BeginMissionSequence;
GMAT angle = DegToRad(0); % B-Plane theta angle (radians, input is degrees)
% Target TCM
Target 'Target Mars B-Plane' DC1 {SolveMode = Solve, ExitMode = DiscardAndContinue, ShowProgressWindow = true};
% Vary TCM
Vary 'Vary TCM.V' DC1(TCM.Element1 = 0, {Perturbation = 1e-2, Lower = -0.05, Upper = 0.05, MaxStep = .01, AdditiveScaleFactor = 0.0, MultiplicativeScaleFactor = 1.0});
Vary 'Vary TCM.N' DC1(TCM.Element2 = 0, {Perturbation = 1e-2, Lower = -0.05, Upper = 0.05, MaxStep = .01, AdditiveScaleFactor = 0.0, MultiplicativeScaleFactor = 1.0});
Vary 'Vary TCM.B' DC1(TCM.Element3 = 0, {Perturbation = 1e-2, Lower = -0.05, Upper = 0.05, MaxStep = .01, AdditiveScaleFactor = 0.0, MultiplicativeScaleFactor = 1.0});
Maneuver 'TCM' TCM(M2020);
% Propagate
Propagate 'Prop to periapsis' MarsFull(M2020) {M2020.Mars.Periapsis, StopTolerance = 1e-05};
% Script
BeginScript
GMAT C3 = M2020.Mars.IncomingC3Energy;
GMAT B = mu/C3*sqrt((1+rp*C3/mu)^2-1);
GMAT BT = B*cos(angle);
GMAT BR = -B*sin(angle); % recall that R is positive "down"
GMAT dV = sqrt(TCM.Element1^2+TCM.Element2^2+TCM.Element3^2)*1000; % TCM dV (m/s)
EndScript;
% Achieve Targets
Achieve 'Achieve B.T' DC1(M2020.MarsMJ2000Ec.BdotT = BT, {Tolerance = 1});
Achieve 'Achieve B.R' DC1(M2020.MarsMJ2000Ec.BdotR = BR, {Tolerance = 1});
EndTarget
Write dV { Style = Concise, LogFile = false, MessageWindow = true }
I moved from an explicit "B.T & B.R" targeting to a perhaps more intuitive "B & $\theta$" representation. Here are a few example output plots, left an angle of 0°, and right an angle of 135°:
