In a small pot, heat oil over medium-high. Add onion and cook until translucent, 5 minutes. Add garlic, season with salt and pepper, and cook until fragrant, 30 seconds. Add tomatoes with juice and bring to a boil. Reduce to a simmer; cook until onions are soft, 15 minutes. Transfer to a blender with cream; puree until smooth. (Use caution when blending hot liquids: Remove cap from lid and cover opening with a dish towel.) Season to taste.
In a skillet, cook bacon over medium-high until browned and crisp, 10 minutes; drain on paper towels. Remove pan with fat from heat. Layer 1 bread slice with half the cheese, bacon, and rest of cheese; top with second bread slice. Return pan to heat. Cook sandwich until cheese is melted and bread is browned, 4 minutes, flipping once. Serve with soup, topped with pesto if desired.