"Good luck" doesn't necessarily mean that you aren't confident in the person. Everyone says that if they want to sound like they care how the person does. It's the most often-heard response to "I have an exam". However, if you want to use something other than "good luck", I also usually say "I hope it goes well (for you)". You can say that as well, and it sounds more like you're hoping the whole situation goes OK, and not just the person's ability to take the exam.