See: https://www.youtube.com/watch?v=xV9spqCzSkQ or https://joythebaker.com/2015/01/whole-roasted-onions/
Garlic can be roasted in similar manner.