Tell him straight up. Unfortunately the only approach is direct or it will get worse. After you tell him, tell your boss the conversation in case the coworker tries to be petty and report you.
I am a manager at my job and see this type of stuff all the time. Could it be he simply wants to be friendly? Sure. Either way itβs better to be direct so there is zero confusion.
I would tell him, βLook John, youβre a nice guy but Iβm not interested in making small talk with youβ. And then just continue your work. If he doesnβt leave you alone after that then itβs time to go to HR. Please do not feel bad. Some people lack self awareness at the workplace and donβt know how to act in a professional setting.