Your comments

actually, it could only be:

float3 lightmap = float3(1, 1, 1);
#ifdef LIGHTMAP_ON
lightmap = DecodeLightmap(tex2D(unity_Lightmap, i.uv2));
#endif
//do whatever

the user could even choose the default color
IMHO, it should simply be a Decode Lightmap node which adds the following code :
Vertex Input Struct :
#ifdef LIGHTMAP_ON
half4 texcoord1 : TEXCOORD1;
#endif

Frag Input Struct :
#ifdef LIGHTMAP_ON
half2 uv2 : TEXCOORD1;
#endif

Shader Variables :
#ifdef LIGHTMAP_ON
fixed4 unity_LightmapST;
sampler2D unity_Lightmap;
#endif

Vert Function :
#ifdef LIGHTMAP_ON
o.uv2 = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
#endif

Frag Function :
#ifdef LIGHTMAP_ON
fixed3 lightmap = DecodeLightmap(tex2D(unity_Lightmap, i.uv2));
// execute whatever you want to do with lightmap here
#endif

However, it would have to handle the fact that LIGHTMAP_ON might be false.