The rules vary by airport. Even when the signs say that the dog must remain kenneled, though, these may not be enforced. I certainly wouldn't hesitate, once I get to my departure gate, to find a quiet corner and let the pooch out (on a short leash) while waiting for boarding.
Relieving should be done outside, which means outside security.
On the plane, the dog must remain kenneled, though if your seatmate doesn't object, you can usually open the kennel top to let the pup stick their head out. If the FA tells you not to, then obey, of course.
What airports are you flying from/to?