Prepare the tomatoes: If using fresh tomatoes, cut them in half crosswise. Scoop the seeds into a bowl and reserve. Using a box grater and starting with the cut sides, grate each tomato half until the skin peels back and all the flesh has been shredded away. Discard the skin. Strain the liquid from the seeds and add to the grated pulp. If using canned tomatoes, seed and very finely chop or grind them through a food mill, reserving the juices.
Make the sofrito: In a large, heavy-bottomed skillet, heat the oil over medium heat. Add the onion and a pinch of salt, and cook, stirring frequently, until pale and translucent, 10–12 minutes. Add the garlic and cook until aromatic, about 1 minute. Add the tomatoes and their juices. Cook, stirring often, until the tomato is darkened and pulpy, adding 1 tablespoon of water whenever the mixture looks too dry, about 20 minutes. Stir in the capers and cook until heated through, 2–3 minutes. Transfer to a medium serving bowl, and cover to keep warm.
Prepare the shrimp: Preheat the oven to 425ºF. Line a large, rimmed baking sheet with parchment paper or foil and set aside.
In a large bowl, add the salt, black pepper, and egg whites and mix well with hands until the salt feels like slightly damp sand. Pour half of the salt mixture in an even layer about ½-inch thick and pat it down lightly. Arrange the shrimp on top of the salt, about a finger’s width apart. Pour the rest of the salt mixture over the shrimp, covering them completely in an even layer and packing the salt down gently around them to seal. Bake until the salt forms a hard shell and the shrimp are just cooked through, 12–15 minutes.
Remove the baking sheet and let cool slightly. Using a wooden mallet or hammer, carefully break open the salt shell into large pieces. Pull any large chunks away from the shrimp. Brush away any salt that clings to the shells and transfer them to a serving platter. Serve immediately with the caper sofrito.