When you have a pet fish that dies you can dispose of the dead fish in several different ways.
When a pet fish dies you can dispose of it in the trash, flush it down the toilet, bury it or even burn it.
When I have fish that die I find that it's easiest to just flush the dead fish down the toilet and be done with it.
Some people take the fish outside and bury it and have a little funeral for it especially if it's a small kids fish which makes it easier on the kid to say goodbye to the fish.
But you can just flush the fish down the toilet and be done with it or just throw the dead fish in the garbage.
Some cities and communities advise against flushing dead goldfish or other pet fish down the toilet because it goes into the sewer treatment plant.
But flushing a pet fish down your toilet is not illegal and even if it were illegal to flush a dead pet fish down the toilet there would be no way for the city to know who did it.
The police or even the city can't tell who flushed what down the toilet and all that will happen is that the fish travels down your sewer pipes and out into the city sewer system.
Then the fish eventually arrives at the sewer treatment plant where they screen things out of it and then the fish if caught in the screening gets removed and thrown in the trash.
Or the fish continues on out and goes into a lake or river.
I've always just flushed dead fish down the toilet and it's never been a problem.