You don't have any control over how the editor itself behaves.
However, you can try to issue On Escape SomeCode before Modi file, and reset it afterwards. Or you can try On Key Label Esc.
Update: This works for me:
On Key Label ESC keyboard "{CTRL+F4}"
Modify file Somefile.txt
On Key Label ESC
>If Esc key is pressed in
>
> MODIFY FILE test
>
>window, Visual FoxPro shows
>
>> Discard changes
>>
>> Yes No
>
>prompt. How to replace this with
>
>> Do you want to save changes to test.txt
>>
>> Yes No Cancel
>
>prompt ?
>
>Yes/No/Cancel prompt appears if clicked in close button in uper right corner of close window.
>How to force it to apper in esc press also ?
>Can ON KEY LABEL esc or some custom edit windows used or other solution ?
>
>Posted also in
https://stackoverflow.com/questions/59425603/how-to-replace-discard-changes-with-do-you-want-to-save-changes