test/mon/test_election: fix memory leaks in Owner and ConnectionTracker
Previously, Owner and ConnectionTracker instances were leaked when
electors were removed from the map while still being referenced by
lambda captures. And ASan rightly pointed this out when running
connectivity.handles_removing_ranks test.
Use shared_ptr to manage their lifecycles, ensuring proper cleanup
even when instances are captured by lambdas after removal from the
electors map.