Short answer
A few small cubes of plain, cooked yam are perfectly safe for a dog that size. As a general rule, treats like this should make up no more than 10% of your dog's daily calories to avoid digestive upset or weight gain. A whole large yam would be too much and could cause a stomach ache or diarrhea. If they've had a sensible amount, just offer water and monitor them.
Yam — Food safety facts
Safe to share · Dogs · full breakdown on the linked food page
Cooked plain. Not the same vegetable as sweet potato, but equally safe.
The full verdict, portion guidance and serving notes are collected on the Yam food facts page.