How could pharmaceutical metabolizing bacteria be used to synthesize them?
In principle yes, because almost all reactions exist in an equilibrium and enzymes are catalysts (meaning they affect mainly the activation energy for a specific reaction).

The best approach is to purify the enzymes in question (probably not even from their original species, but from another transgenic bacterium), since this reduces your total systems from two different organisms and all their enzymes and metabolites to a very specific set of two enzymes and a handful of metabolites.

But ...


The natural equilibrium of the reaction might favor the more basic metabolites.
Even if you speed up the generation of "P", that won't help much if only a fraction is converted in the first place. Many biological systems deal with this problem by coupling unfavourable steps with hydrolysis of high energy molecules (like ATP), but linking to this to a given enzyme would be a very challenging process.
The enzyme(s) might not be overly specific for "P".
Many enzymes that remove or break down 'unwanted' products can act on multiple similar molecules. This make sense for cells, since its much more efficient to have one enzyme taking care of multiple 'bad things'. However, this makes reversing the process tricky since your reaction will yield multiple products of which only one is interesting. Optimising the enzyme to be more specific is relatively straight forward using in vitro evolution though.
'Basic metabolites' is not a clearly defined thing.
Many pharmaceuticals are pretty complex, and enzymes that break them down likely literally chop it into two pieces. Whether these pieces are actually easy to obtain chemicals that can be used as input for an enzymatic reaction is a different question. Depending on the complexity of 'P' you might have to use a pretty large number of enzymes (all of which may come with the above mentioned problems) to be able to start from reasonably basic molecules.