i had personally a similar problem as yours when i was younger . before considering going to the gym you should visit your doctor for a general checkup , blood pressure cardiac auscultation etc... just to make sure everything is going well .
the other thing is if you want to gain weight going to the gym will definitely help you , keeping in mind to have healthy diet , being underweight
doesn't mean you can go and eat whatever junk food you have in mind , you can ruin your lipid profile
and you might gain FAT which is i dont think you have in mind . being underweight is a chance for you to build up a fit body in the right pace of time right exercise and good diet .
for the supplement any weight gainer would help but it's not an alternative to healthy balanced diet.
i hope i answered your doubts .
Please rate my answer if you find it helpful .
Thank you .