If locking, then unlocking the phone fixes it, it's not the screen. It's also probably not a software issue because the only software affected when you lock the screen is the app you're currently running in the foreground. So if it always happens when you're running the same app, that app is the problem, otherwise it's something a shop would have to troubleshoot. It could be some app running in the background that's locking the whole phone up, making the screen unresponsive.
See if you can duplicate the problem while you have music (or a radio or some sound) playing that will play in the background (many players stop if they go into the background - my local NPR station's app doesn't). If the sound also stops when the screen freezes, it's the phone that's freezing. If the sound continues but the screen is frozen, it's probably something to do with the screen or (let's hope not) the motherboard. Knowing those things will give a repair shop more information, so it will save them time, saving you money. (The more you can diagnose, the less the repair will cost.)
Even doing a screen test (all red, all green, all blue, all black and all white) won't tell you anything unless the screen freezes during the test - then it will tell you that the screen is frozen.