Have you discussed this with your doctor/dietition yet? If not, it probably would be wise to.
Being heavier than ideal is so common today, even among those who regularly cycle, that many assume that everyone wants/needs/can afford to lose weight... when that's clearly not the case. I've been steady at a slim weight forever. Can't gain no matter what I eat. Riding on empty surely would burn something I'd rather not lose. Since you actually want to gain weight, riding without fuel would be an even bigger mistake. Listen to an expert who better knows and understands your body and situation.
I wish you well and hope to see a positive update.