Would both seats be contested in the same ballot,
Yes. At least they could be.
and if so, how would it be determined if who receives the full 6-year period, and who the remainder of the prior senator's period?
They choose the seat for which they run, the same as with House seats.
This isn't that uncommon. The case that comes to mind quickly is Barbara Boxer and Dianne Feinstein in California were both elected in 1992. This also happened in both Oklahoma and South Carolina in 2014, but incumbents were reelected to the six year terms. Same thing in Mississippi in 2008. I didn't keep looking prior to 2008.
Not directly related to your question, but there are some interesting tactical reasons to choose the shorter period. For example, the shorter period may take office sooner. Once the vote is certified, there is nothing blocking the Senator from taking a vacant office. They might even be able to displace an appointed Senator. This gives greater seniority to the short term Senator than to other new Senators, who can't take office until the previous holder leaves. Feinstein has seniority over Barbara Boxer for that reason.
The reason to choose the longer term should be obvious — more time until the next election.