Energy storage systems (ESSs) have been considered to be an effective solution to reduce the spatial and temporal imbalance between the stochastic energy generation and the demand. To effectively utilize an ESS, an approach of jointly sharing and operating an ESS has been proposed in a conceptual way. However, there is a lack of analytic approaches designed to optimize the operation of such a system considering interactions among users in a game theoretic perspective. In this study, we propose the energy capacity trading and operation (ECTO) game where each agent determines two actions, capacity trading, and the 24-hour ahead charging-discharging scheduling with the capacity that will be assigned, to minimize the energy operation cost. We then propose a distributed optimization strategy to find a generalized Nash equilibrium for the proposed ECTO game. Simulation studies show that when optimally operated, a shared ESS can decrease both the total energy operating cost and the peak-to-average ratio of the energy for the entire grid compared to the conventional ESS control strategy without ESS sharing.