There is no law defining pin positions, but there are clear recommendations, worked out over many years by folk who spend much more time considering these things than we do.
Let's consider the USGA for one.
Rule 15-3(ii) recommends that holes should be placed "at least four paces from any edge of the putting green," and even farther if there's a sand trap near the edge or if the area surrounding the green's edge slopes downward.
It is down to the good judgment of the individual/s involved to place the hole in a sensible location given the factors involved in each case (distance of approach, slope, wind, etc). Put it four-feet from the edge if you want, but be prepared to be ridiculed, abused and relieved of your responsibilities!
To address Duncan's point about narrow greens. I think we would need some proof of the claim before we can accurately assess the situation. If you consider that an average UK tee is in the range of 6-10 metres wide, it would be most unusual to find a green with dimensions as slim as this. At the narrow end of this range one would struggle to avoid placing the hole cups in anything other than a line down the middle. In this case, it is likely that there has been some regression of the green edge over the years and a case could be made to restore or widen the green on the basis of spreading wear. I note Duncan mentioned extending a green for this purpose.
My own benchmark when designing greens is to draw an inner ring 3 metres in from the edge and to have the hole location zones out to that limit. That equates to about 4 paces. It has served me well over 30+ years. Where the GK cuts the pin is up to them, but I do not ever remember seeing a hole cut 4-feet from the edge in anything other than a 'Greenkeeper's Revenge' event. Fun for the odd silly Saturday, but a freak show in all other instances.