it is naturally not possible to start an Ausbildung as an illegal person. The company or school which takes such trainee, breaks the law and makes a criminal case, with bad consequences.
To start Ausbildung you must have one of the following options 1) a visum to come to Germany for this Ausbildung from a German embassy abroad 2) a legal residence permit in Germany with which you don't need any permission 3) if you don't have a residence permit you must be officially in an asylum procedure with Aufenthaltsgestattung or you must have a Duldung - in both cases you must ask for a permission to do this Ausbildung from the Ausländerbehörde in the place where you live.
That means you must first stop to be illegal and get at least a Duldung and with it try to get an permission. The problems are the penalty for your illegality, which can lead to a ban on any occupation (Ausbildung is a kind of "Beschäftigung" or occupation) and the need to give the Ausländerbehörde some documents as a proof of your identity which is always a condition to have a permission for work and Ausbildung if you have Duldung.
If you ask for asylum, you must normally live in a camp for months and have a ban on occupation there, so the Ausbildung won't be possible in near future. If it can be possible later, depends on too many factors to analyse here.
This is a general information which is not enough to evaluate your chances. You must seek für a good councelling center for migrants or, better, consult a good lawyer specialising in alien law.