A rough plywood shelf edge will not look good if you simply paint it with the rest of the shelf.
Even after sanding it smooth, it will not take paint well. And if you are going to paint the shelf, you shouldn't waste your time and money trying to put glue-on trim on the edge.
To get it to look good, first sand the edge smooth.
Then you need to fill all the little holes by forcing polyfiller or a wood filler into the edge. Then sand that all off, leaving filler in the holes only.
Now use a primer-sealer over the entire shelf. You will notice that the primer-sealer will soak in unevenly, almost disappearing where you have end grain, soaking in fairly well where you have filler, and soaking in less where you have side wood grain. The primer-sealer is not supposed to look good. What it does by soaking in unevenly is seal everything to the same porosity, so that the first coat of paint will soak in evenly all over this shelf.
You may not need a second coat of paint.