Place chicken breasts between two layers of plastic wrap or inside a large disposable plastic bag; pound with a meat mallet or rolling pin until an even thickness, starting at the thickest part and working outward.
Season both sides of the flattened chicken with Italian seasoning, salt, and pepper.
Heat a skillet or electric grill over medium heat and lightly oil the surface if using a skillet.
Cook the chicken 5–8 minutes per side, until an instant-read thermometer inserted into the thickest part reads 165°F (74°C). Transfer to a cutting board and let rest 5 minutes.
Slice the rested chicken into 1/2-inch-wide strips.
Spread mayonnaise (if using) and pesto on the sourdough slices, dividing the pesto from the 1/4 cup as desired.
Top half the bread slices with sliced chicken, tomato slices, and a slice of Swiss cheese; close sandwiches with remaining bread slices and lightly brush the outsides with olive oil or a thin layer of mayonnaise to promote browning.
Cook sandwiches in the skillet or on the grill over medium to medium-high heat until the first side is golden, then flip and cook until both sides are golden and the cheese is melted (work in batches if needed).
Place finished sandwiches on a plate in a warm oven while you cook the remaining sandwiches, then serve warm.