Generally speaking, this is illegal. I won't do training at my own expense unless it is promising.
If the company thinks you have potential, you can be bound by signing a contract or training agreement, and you are definitely not required to pay directly;