Fasting can help increase testosterone levels, however context is important.
Peak testosterone production in a male occurs at roughly 9 a.m. Testosterone is made in the testes in males, however the precursor to testosterone is DHEA. DHEA is synthesized from pregnenolone, which is created from cholesterol under the right conditions.
Clinically, I have found that people who choose to engage in intermittent fasting choose to skip breakfast and opt to drink coffee in the morning to suppress their hunger. When they choose to engage in this sort of fasting, what tends to happen is they induce a hyper-cortisol and eventually to a hypo-cortisol state which over time leads to chronic "pregnenolone steal syndrome". At this pointt, pregnenolone becomes continuously shunted to the production of cortisol instead of the sex hormones. Additionally, they push their feeding window later into the evening, and in doing so suppress the growth hormone release which would normally benefit them in the evening while they are in the fasted state during sleep.
In cases where people want to reap the benefits of fasting, I recommend eating a moderate-protein, higher-fat, moderate carbohydrate breakfast upon waking up, and an early dinner which would be high protein, moderate fat, and lower carbohydrates. Because protein synthesis can be amplified up to 400% in the early evening hours (4-6pm) in normal circadian cycles, those who engage in heavy anaerobic lifting can increase muscular gains without ingesting abnormally high levels of protein.
Eating this was allows for 2 benefits: a 7-8 hour fasting window during the day, and a 14-16 hour fasting window during the evening. Not eating 4-6 hours before bed can further amplify growth hormone effects, as well as proper leptin signaling for fat loss as well.
Exercise during the fasting window can increase growth hormone signalling, which can amplify testosterone production.
Note that this is all context dependent. People with chronic adrenal fatigue issues, reactive hyper-hypoglycemia, and any other endocrine/circadian imbalances will need differing amounts of meal frequencies, compositions, etc. I have found that in my practice, the majority of low testosterone patients have issues with the hypothalamic-pituitary axis (I call this a problem with headquarters). When this is the case, fasting is the last thing I recommend to these patients. Fasting induces a stress response, and in these patients they are already suffering from chronic pregnenolone steal.
There are some specific herbs, vitamins, and minerals that I use with my patients depending on where they fall on this spectrum. If you have any more questions, feel free to contact me.