In this paper, we propose a novel multivariate shortfall risk measure to evaluate the systemic risk of a financial system, where the allocation weight is scenario-dependent and optimally chosen from a predetermined feasible set, and examine its properties such as (quasi-)convexity and translation invariance. To compute the proposed risk measure, we reformulate it as a two-stage stochastic program. When the underlying risk is discretely distributed, the second-stage program is a finite convex program while for the continuous case, is a semi-infinite program. To tackle the latter, we use the polynomial decision rule to approximate it and reformulate it as a tractable optimization program via the standard sums-of-squares techniques. Some convergence results are established for the approximation scheme. Moreover, we apply the proposed risk measure to the risk capital allocation problem and introduce the scenario-dependent allocation strategy. In contrast to the existing allocation methods, the new approach considers losses of all scenarios and minimizes the systemic risk. We then carry out some numerical tests on the proposed model and computational schemes for a continuous system, a discrete system, and a risk capital allocation problem in life insurance. The results show that our allocation strategy performs better than the Euler allocation rule based on the expected shortfall and the method by Armenti et al., 2018, and is robust to the (un-)systemic changes of the considered dataset. Finally, we extend our model by incorporating the cost of risk capital and investigate its impact on the optimal total amount of risk capital.