Code:
$
$ cat file1
dn: cn=MarquisA,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
ndsHomeDirectory: cn=APMMTL02F25_MRC1,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\REPLACEHERE
dn: cn=MarquisB,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
ndsHomeDirectory: cn=APMMTL02F25_MRC2,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\REPLACEHERE
dn: cn=MarquisC,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
ndsHomeDirectory: cn=APMMTL02F25_MRC3,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\REPLACEHERE
dn: cn=MarquisD,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
ndsHomeDirectory: cn=APMMTL02F25_MRC4,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\REPLACEHERE
$
$ perl -ne 'BEGIN {$x="### INSERT LINE HERE ###\n"}
> { if (/^dn: cn=(.*?),/) {$cn=$1; $done=0}
> elsif (/^changetype:/) {$_ .= $x}
> elsif (!/HomeDirectory/ && $done==0) {s/\\.*$/\\$cn/; $done=1}
> print
> }' file1
dn: cn=MarquisA,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
### INSERT LINE HERE ###
ndsHomeDirectory: cn=APMMTL02F25_MRC1,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\MarquisA
dn: cn=MarquisB,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
### INSERT LINE HERE ###
ndsHomeDirectory: cn=APMMTL02F25_MRC2,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\MarquisB
dn: cn=MarquisC,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
### INSERT LINE HERE ###
ndsHomeDirectory: cn=APMMTL02F25_MRC3,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\MarquisC
dn: cn=MarquisD,ou=PTG,ou=MTL,ou=QUE,o=ASDASD
changetype: modify
### INSERT LINE HERE ###
ndsHomeDirectory: cn=APMMTL02F25_MRC4,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\
TVG\MarquisD
$
$