You can race hare and hounds on a MX bike (generally have specific classes). More beginner friendly than a MX event.
Lets not run before the Op can walk, he’s not even ridden a proper motorbike yet. Firstly the Yz is a great bike and 2 strokes are the in thing at the moment. If it’s as cheap as you suggest you can buy it for polishing practice and make money. At my local track https://www.facebook.com/groups/314457776260/ they have a junior track, as a raw novice you can ride around that to get used to the bike. You will be lapped by the 8yr olds, but people won’t laugh…….much.
Once it gets busy they split the riders on the main track into novice, intermediate and expert sessions. I assume other tracks have a similar policy. It can be dangerous, but not dissimilar to mountain biking, certainly if you only do practice days. Stay within you limits and injuries can largely be avoided. It’s just bad luck if something happens. Racings different, there’s no point being there if you aren’t testing yourself and other riders will be racing you aswell, accidents are far more common.
If you’ve got the itch it won’t go away untill you scratch it, but be prepared for it to be a lifelong passion if the bug really bites.