Welcome to the Wefugees Community and thank you for reaching out to us.
Without knowing your background or at least your type of residence permit in Spain, it is hardly possible to give more concrete advice. However, I am afraid that you most probably don't have "the right" to make an "Ausbildung" (vocational training) in Germany automatically with holding a Spanish temporary residence permit. Nevertheless, you might be able to apply for a respective visa at the German embassy in Spain and subsequently for a residence permit. As I am not an expert on these topics, I will link two of my colleagues here as well. Dear @mbeon-fardeen or @mbeon-Ruth, can you help out?
You may also check the "Make it in Germany" website for more information.
All the best,