The bike I own is a pretty old Nishiki 351 Hybrid bike, so any branded spare parts are pretty hard to find. Now I have this issue of missing a top cap from the fork (see image). What kind of cap should I buy for it? Is it bad if water gets inside for example if bike is left out in the rain?
Normally I'd say that the top cap isn't strictly necessary, until you need to adjust your stem, at which point you need it to properly load the headset bearings. Water getting in there isn't much of an issue as it would just flow out the bottom of the head tube. That being said, from the picture I have never seen one that looks like the one in your picture. It should look like the second picture from this post. In general you should not leave your bike in the rain, but water getting in the head tube wouldn't be a huge worry of mine.
It's also worth noting that not having a top cap could be a safety issue in the even of a crash. Any open tube would be much more likely to cut you if you rammed against it.
I was able to find the assembly instructions for that headset and it seems that this type of adjustable stem that you have doesn't require at top cap with a nut (see page 13 for bearing load adjustments). in this case the top cap seems to be purely cosmetic. See the top cap shown on page 25 in the exploded diagram. You might want to look for something else to plug the whole with if you are worried about the possibility of the open tube being a danger in a crash.