I don’t think Loki knew 100% it was Thor coming to get him but just largely suspected. Loki has been on Earth a while now with this being one of the biggest public displays... for a reason. He’s likely aware that the Asgardians have been looking for him by the use of Heimdall1. It makes sense after a large public display of attacking humans that Heimdall would spot him
Click image to enlarge.
Note that Thor gives the reason above for why Loki’s plan not only attracted the Avengers but Thor as well: he’s attacking Earth; a planet Thor loves and as sworn to protect. Even if he wasn’t aware Thor would come down in Germany he would have known he’d be down there in time for New York. That coupled with the lighting/thunder made him reasonably sure it was Thor.
That said Thor is actually producing the lightning/thunder himself during that scene whilst flying with Mjolnir as we see in Thor: The Dark World Prelude.
Click image to enlarge.
We do know that Thor’s lightning is slightly different to normal in the way it emanates from Thor/Mjolnir. It’s also worth noting the lightning was created by Thor as he flew along here, the movement of it could have helped Loki realise what was happening.
I think another point to make here is that Thor’s landing on Earth wasn’t exactly smooth as we see above. Potentially Loki saw/heard that as well and put two and two together. We also know that Thor was revived with Mjolnir like he was in Thor in New Mexico when fighting the Destroyer. If Loki was in range he may have detected the event and made the same connection.
Overall it’s a matter of putting a few factors together and coming to the conclusion that is is likely Thor. That said he didn’t necessarily think it was him, it’s just a flippant comment making the connection between Thor and lightning/thunder.
1It’s noted in a conversation between Loki and Heimdall in Thor after Loki returns from Jotunheim that Loki has managed to hide himself from the other’s gaze. It’s possible that Loki can also detect when Heimdall is looking for him rather than always hiding himself.
Loki: What troubles you, gatekeeper?
Heimdall: I turned my gaze upon you in Jotunheim but could neither see you nor hear you. You were shrouded from me like the Frost Giants that had entered this realm.
Loki: Perhaps your senses have weakened after your many years of service.
Heimdall: Or perhaps someone has found a way to hide that which he does not wish me to see.