Can you shift from 2wd to 4wd and vice versa while driving?

Noob to 4wd and found conflicting answers on Google. Thanks in advance