Place the chicken breasts between two layers of plastic wrap or inside a large resealable bag and pound with a meat mallet or rolling pin until they are an even thickness, working from the thickest part outward.
Season both sides of the flattened chicken with Italian seasoning, salt, and pepper.
Heat a large skillet or electric countertop grill over medium heat and lightly oil the surface if using a skillet.
Cook the chicken breasts 5 to 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.
Assemble the sandwiches: spread mayonnaise (if using) and some of the pesto on each slice of sourdough. Top four slices with chicken strips, tomato slices, and a slice of Swiss cheese, then close with the remaining bread slices.
Lightly brush the tops and bottoms of each sandwich with olive oil or a thin layer of mayonnaise to encourage browning.
Cook the 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 the other side is golden and the cheese is melted. Work in batches if needed.
Place cooked sandwiches in a warm oven while finishing the remaining sandwiches, then serve immediately.