I currently received a request in which the document/folder should be locked after (x)days (after the created date). Is it possible to enforce document/folder locking?
You can enable In Place Record Management Feature on your Site Collection, and configure the record declaration settings in such a way that those document which are declared as records are not allowed to be either edited or deleted (locked to be precise.) as shown below:
Go To Site Settings -> Site Collection Administration -> Record Declaration Settings
Next, set up Information Management Policy Settings on your document library for the Content Types Document and Folder
Add a new retention stage and configure it as shown in the image below:
You should be able to achieve your requirement this way in a completely out of the box manner. Alternatively you write a Timer Job in order to achieve the same thing programmatically.