Hi guys. Been having this problem for soon long and Its so annoying. I don't have a total fix but something which may help some of you. I mainly use apple music so theres only a few tracks on my mac that i want on my phone that aren't available such as downloaded mixtape etc. They play fine on my iTunes and sync to my phone only to show as grey and do not play whatsoever, they even crash my phone slightly if it comes on shuffle. So annoying. However if you have iCloud music library turned on you can actually right click the tracks you're having problems with on your computer iTunes library and select 'add to iCloud music library'. It should be second on the list directly underneath 'add to playlist'. There will then be a loading circle show on top right hand corner of iTunes screen as it uploads. Once its finishes it should now show in your music library on your phone as long as you have everything set to sync across devices.
If this DOESNT show as an option iTunes is being a pain in the *ss but its ok theres still a way. You will need to delete the song from your iTunes, it should prompt and say that it will also download from iCloud library. Ok this.
Next locate the actual audio file on your hard drive wherever its been saved, double click, should automatically open and play in iTunes. The add to iCloud music library option should now be there.
This workaround only works one track at a time which is a bummer but if theres certain songs your desperate to be able to listen to on your phone its good enough.
Sorry if I've used wrong computer terms and if this is confusing but i don't know a lot about computers and terminology etc
Hopefully this will help at least one person!