Where should I put a modified version of l() function?
You should put it in your custom module. I think it's anyway good development practice to have a custom module in every project you develop.

What I do usually, is that I create MY_MODULE.helpers.inc file, and include it at the top of the .module file.

Here's an example of .module file:

// Get helper functions.
require_once dirname(__FILE__) . '/MY_MODULE.helpers.inc';


This way, if your module is enabled, the function will become available to other modules or your theme, and your .module file is cleaner because it doesn't include the helper functions.

You can see my Drupal 7 Boilerplate and specifically the boilerplate.helpers.inc file on Github.