How to modify how the_content outputs a link to an internal page

I’m in a hurry so don’t have time to provide any code, pseudo or otherwise, but you could probably do this in the the_content filter by using a regex to find all links and for each one find the page/post ID using url_to_postid and then replacing as appropriate.

Good luck!