Porting PyMC code to run on PyMC3 how to create a stochastic subclass distribution?

Yes you will use DensityDist for this. The conditional (i.e., parent information) could be coded in the logp function directly, or feeded using a dict in observed={…}

You can have a look at How to set up a custom likelihood function for two variables for more information.