Ghostwriting is creative writing that you do and someone else claims as their own work. Normally, you must sign a paper stating that you give all rights of every kind for the manuscript that you actually wrote to the buyer and that you will never divulge that you did the actual writing.
You don’t learn ghostwriting as a kind of writing, instead you learn writing and then look for ghostwriting jobs, usually on one of the sites that put professionals of all types in contact with people who are looking for their expertise. There are several.
One caveat you should know if you are a writer and want this type of work. You must bid for jobs on these sites and when you do so, you will be bidding against writers who will charge very little for their services. Sometimes as little as $5.00 for an entire book.
Yes, those books will be worth $5.00 and, yes, the people looking for a writer should know that, but they often don’t.
If you persist and can get enough jobs to keep going, then eventually you will become known for your good work and can charge and make a decent amount of money. But it can take a long time.