It depends on the instrument you play, its sustain, and on the speed and loudness you play the piece at.
Basically, you want the attack of the second B without a release of the first B. If the sustain of the instrument is strong enough and the second voice is loud enough, just smoothly releasing the G "legato" and then moving on to the C next beat may work fine, particularly on instruments or volumes with a comparatively soft attack.
Otherwise you release the B not far enough for the tone to dampen and let it strike again with a volume appropriate for the first voice.
The latter option will work particularly well on grand pianos (which tend to have a repeat mechanic that supports this kind of option) but is also feasible for pianos.
On a harpsichord, you'll also want to repeat since the attack has a very characteristic sound and its absence would be quite noticeable. On a harmonium/organ/accordion, not interrupting the B at all might be preferable.
Try it out and see which execution better allows your hearing to focus on either line without too much irritation.