Sforno on Genesis 42:7:
ויכירם שהם אחיו לא שהכיר אחד לאחד:
He recognized (collectively) that they were his brothers. But he couldn't distinguish one from the other (he didn't know who was whom.)
If so, we see Genesis 42:24:
וַיִּסֹּ֥ב מֵֽעֲלֵיהֶ֖ם וַיֵּ֑בְךְּ וַיָּ֤שָׁב אֲלֵהֶם֙ וַיְדַבֵּ֣ר אֲלֵהֶ֔ם וַיִּקַּ֤ח מֵֽאִתָּם֙ אֶת־שִׁמְע֔וֹן וַיֶּאֱסֹ֥ר אֹת֖וֹ לְעֵינֵיהֶֽם׃
And he turned himself about from them, and wept; and he returned to them, and spoke to them, and took Simeon from among them, and jailed him before their eyes.
How does Yosef know who Shim'on is? He must know who Shim'on is because he picks him specifically:
Shadal on Genesis 42:24:1:
את שמעון: אחר ששמע כי ראובן אמר אל תחטאו בילד, אמר א"כ מי שבא אחריו בסדר תולדותם הוא היה המסית אותם, כי מסתמא הקטנים נשמעים לגדולים, ואם שני האחים הראשונים, ראובן ושמעון, לא היו מסכימים בדבר, לא היה נעשה.
After he heard Re'uven (assume that Yosef has no idea who Re'uven was) said "don't harm the child", Yosef assumes that the next oldest must have been the one who advised the others to harm "the missing brother" as it is customary for the younger ones to listen to the older ones.
So, somehow, at this point, even if Yosef doesn't know the name, he at least knows who the 2nd oldest brother is, as this is the one whom he jailed.