Ho to make Custom Field Mandatory in Sales Order Line

I have custom field in sales order line, I want make this as mandatory based the item selected in sales order line…

Please suggest where can I write logic and any similar example

You can add a validation to validateWrite() method of the table.
You can also use mandatory() method of the data source field to show the field as mandatory. This logic belongs to active() method of the data source.