I'm new to this topic, I've just reviewed some lectures on the Langrangian. I'm not entirely sure how analagous the costate variables and Lagrangian are, so I may be conflating things?
I see that the Hamiltonian is a function of the costate variables. If I remember from my lecture videos, the Lagrangian is obtained from only the constraint and the function you wish to maximise. I don't see an analagous way to obtain the costate variables.