In Dynamic365 to check if the form is modified or not we need to use getIsDirty() method.
Please check the below code which i have written in JavaScript.
Source Code
function checkModified(paramContext){
var isModify = Xrm.Page.data.entity.getIsDirty()
if(isModify == true){
console.log(“modified”)
}
}
Finally, In Model Driven Apps we can call this method on onChange property of field and then publish the form.