I don't think there is any automatic way of deciding upon the RAM configurations.
You will have to do several executions (including some with cold starts) and see what is the range of RAM consumption and then add some buffer on top of it.
That's how we did it.
Regarding "Ideally, the method/procedure should be language agnostic", yes that should be true, although a point to note here would be that the actual RAM requirements/size would not be language agnostic, because different languages might need different memory footprint for doing the same task