Is it possible to publish a movie from iMovie to youtube if you have two factor authentication on?
For apps that don't support two-factor authentication, such as iMovie, you need to generate an application-specific password. This is a computer generated password that can be used to give an app access to Google services, but is intended for use in a single app.

Go here to manage your connected apps and application-specific passwords. Once you generate one (be sure to label it as "iMovie password" or similar), copy it into iMovie making sure to use your full Gmail address as the "Account Name", then you're done with it.

There's intentionally no way to view the password again, the only possible action is to revoke it. This way your account still stays secure as long as the app stores the password securely (and if it doesn't, you can always revoke that one password without causing problems for the rest of the account).