Preheat oven to 350 degrees F. Coat eight 2 1/2-inch muffin cups with cooking spray. Gently press a ham slice onto the bottom and up the sides of each prepared muffin cup, carefully ruffling the edges of ham. Divide cheese among the ham-lined muffin cups.
Break an egg into a measuring cup and slip egg into a muffin cup. Repeat with the remaining eggs. Sprinkle with pepper. If desired, spoon 1 teaspoon of the pesto onto each egg. Top with tomato halves.
Bake for 18 to 20 minutes or until whites are completely set and yolks are thickened. Let stand in muffin cups for 3 to 5 minutes before serving. Carefully remove egg cups from muffin cups.