You can't do both with one y-valve
Because they each have to be in a different line. To flush a toilet directly overboard, a y-valve would have to be installed in the the toilet discharge line to provide a choice of going directly overboard or into the tank. (Who says that's not the preferred method?)To have the ability to dump a tank, you could have a y-valve--or there may be only a tee (which many boat builders use to save money) in the pumpout line to provide a choice of pumping out or going overboard via a pump. Or, the tank could be fitted with two discharge lines...one going directly to the deck pumpout fitting, the other going directly to the pump and then the thru-hull.