You know the drill in pretty much every game that features some sort of "Devil Trigger" or "Rage of the Gods" mechanic (Devil May Cry or God of War respectively).
Typically you want to save this game-changing power for a tougher encounter, or to save your bacon last-minute in a pinch. But in Nioh 2, given that using it liberally helps you level the form up with its own skill tree, you'll want to forget what you know.
To trigger your Yokai Shift ability, you just need to press Triangle and Circle at the same time when your gauge is full (pictured below). From there you have access to a host of new abilities and temporary immunity (getting hit costs you gauge and turns you back sooner): typical Devil Trigger stuff. It comes in handy during boss fights to sort of sleepwalk through tougher phases, so in certain cases, saving it makes sense.
But when walking about levels randomly: make sure you trigger Yokai Shift every chance you get. By the time you reach the boss you might end up leveling it up, and trust me: you'll know when that obvious boss door is within reach.