This is an excellent idea. It is called "back priming". The practice is priming all sides and the cut ends before installation. After installation the trim is caulked and then painted.
It isn't necessary to paint the back. The primer will seal it and protect your investment.