Extension vs Class For ViewModel
The viewModel property on the Extension example should be removed as it is redundant:

lazy var viewModel: ViewModel(main: self)


Irrespective of this, it seems unnecessary to create a separate ViewModel class solely for the purpose of encapsulating a configureView function. On that basis, the Extension approach seems like a much more sensible and performant way of managing this kind of configuration.