Is it possible to have a 11-42 cassette with a 3x9 drivetrain?
Yes it is possible.
It will be a nightmare on your chain and arguably not a good idea.
If you want to use a 9 speed rear derailleur with a max tooth of 36t, you can make it fit a 42t cassette with a derailleur hanger extender such as the Wolftooth Goatlink

Your biggest problem will be the front 3 rings. You will find that if you may have problems when crosschaining. Although, you could argue that you should never be doing that anyways.