Maximizing custom likelihood

I think there might be ways to do what you want using the posterior samples. At least for estimating the marginal likelihood (as one number, not a function as you want), there are multiple ways (e.g., see my blog post on this)