Fasting for 12-24 hours will likely not injure you. However, you need to eat a surplus of nutrient dense food to regain weight. So if you were to fast daily from 12-18 hours, make sure for your weight goals you are eating enough. Try r/intermittentfasting. Extended fasting is not recommended for those who are underweight.
You should not do an extended fast if you are underweight. You can still get a lot of the benefits of fasting while doing a 20:4 IF schedule or 23:1 (OMAD). And make sure that during your feeding window that you are consuming an entire day’s worth of calories.
Be safe.