Shape optimization problems for metric graphs