A swarm of cooperating UAVs communicating with a distant multiantenna ground station can leverage MIMO spatial multiplexing to scale the capacity. Due to the line-of-sight propagation between the swarm and the ground station, the MIMO channel is highly correlated, leading to limited multiplexing gains. In this paper, we optimize the UAV positions to attain the maximum MIMO capacity given by the single user bound. An infinite set of UAV placements that attains the capacity bound is first derived. Given an initial swarm placement, we formulate the problem of minimizing the distance traveled by the UAVs to reach a placement within the capacity maximizing set of positions. An offline centralized solution to the problem using block coordinate descent is developed assuming known initial positions of UAVs. We also propose an online distributed algorithm, where the UAVs iteratively adjust their positions to maximize the capacity. Our proposed approaches are shown to significantly increase the capacity at the expense of a bounded translation from the initial UAV placements. This capacity increase persists when using a massive MIMO ground station. Using numerical simulations, we show the robustness of our approaches in a Rician channel under UAV motion disturbances.