DM's call
Provided you can squeeze into the Bag, with its 2ft diameter opening; if you were inside a bag of holding, or any other extra-dimensional space, the relevant part of Banishment is as follows:
If the target is native to the plane of existence you’re on, you banish the target to a harmless demiplane.
...
If the target is native to a different plane of existence than the one you’re on, the target is banished with a faint popping noise, returning to its home plane.
Extra-dimensional Space is not necessarily a plane in it's own right, the DMG contains only a small paragraph on Demiplanes, most notably:
Demiplanes are extradimensional spaces...
However nothing is said about whether all extra-dimensional space is on, or is entirely, a plane/demiplane. "All Dogs are Mammals" does not mean all "Mammals are Dogs".
So there are a few options:
- The extra-dimensional space inside a Bag of Holding is a demiplane:
The usual rules of Banishment would apply. You can escape from the Bag.
- The extra-dimensional space inside a Bag of Holding is not a demiplane: Banishment would not work. You can't escape from the Bag.
- You are treated as being on the same plane as the exterior of the Bag of Holding: The usual rules of Banishment would apply. You can escape from the Bag, but only to a different plane.
It's down to your DM to decide which of these options is taken, bearing in mind that if, as per the above rulings, you count as being native to the plane you're on when you cast it, you would be sent to a harmless demiplane and become incapacitated as per the description of Banishment, thus immediately losing concentration on your spell, and returning to the inside of the Bag.
A spell that would definitely work? Plane Shift:
You and up to eight willing creatures are transported to a different plane of existence.
This has no prerequisites regarding your current plane, and requires no concentration/Saving Throw, so you would be free to escape the bag.
*This answer has been edited to take into account the comments from multiple users.