If the person believes that trying to fast 1 or 2 days is not harmful to his health, then yes he is allowed to try even if his doctor advises him not to. But if he believes that trying to fast a day or two will harm him, then he should not. As long as he doesn’t believe he will be harmed, then he can try fasting.