If someone came to the US on a J1 visa with a residency requirement of two years and that person returns back to the home country and then would like to return to the US on an F1 visa to continue a master's degree, can a visa be issued before the residency requirement is completed and does the new F1 visa if given, get rid of the J1 residency requirement?
The two-year home residency requirement does not prohibit issuance of F-1 visa. That can be tried any time, even before the HRR is completed. Ultimately, F-1 visas are discretionary. But there is no law that prohibits their issuance in these circumstances.
Issuance of an F-1 does NOT waive the HRR. You will stay subject to it.