Matrix Pontryagin principle approach to controllability metrics maximization under sparsity constraints