Whether the monster uses a lunar script or not is determined entirely by whether you are on the moon or not.
So if you put lunar monsters in the Overworld, they will use entirely different battle sequences.
... Did that answer your question?
How do I know if a monster is on the moon? Is there a formation data somewhere that would have monsters IDs and map ID?
Not quite Chillyfeez, if you notice the Monsters on the Moon have normal AI setups in addition you can fight Slime and Tofu on Earth.
I tested this with Eukaryots and put them on Earth with a changed AI Setup (because the fight AI are basically the same from Moon to Earth) and they followed the changed AI setup from the Earth which the editor said they would.
There really aren't that many monsters on the moon and those that are only have their routines changed purely by index are in Bahamut's Cave and the Lunar Subterrane (We can see this in the Lunarian Lobby as well with the glitch "Treasure Monster" which proceeds to petrify itself) There is nothing signifying a monster should be Earth or Moon, you could put an Imp in the Lunar Subterrane and it's only problem would be its AI script would be askewed. I will take a look though. But generally every map after 346 (15A) except for the Lunar Passage maps would apply. For the record, Prokryot, Eurakryot, Red Worm, Moon Cell, Pudding, Grenade, despite being on the Surface and in the Lunar Passages do not count as Moon monsters. I'll do a quick ASM search and try to find out exactly why this is...
Found it! Much easier than I thought it would be to find, actually... breakpointed a Read on 1700 as battle occurs. I can see why you thought it worked that way Chillyfeez, but the game never checks if you are on the Moon, it just checks to see if you are in an area (03 is always area) so...
$00/874B AD 00 17 LDA $1700 [$00:1700] A:000D X:0180 Y:0000 P:eNvMxdizc - Load A from World Index
$00/874E C9 03 CMP #$03 A:0003 X:0180 Y:0000 P:envMxdizc - Is it an area?
$00/8750 D0 23 BNE $23 [$8775] A:0003 X:0180 Y:0000 P:envMxdiZC - If not, branch past.
$00/8752 AD 01 17 LDA $1701 [$00:1701] A:0003 X:0180 Y:0000 P:envMxdiZC - Load Map Index Byte
$00/8755 F0 1E BEQ $1E [$8775] A:0001 X:0180 Y:0000 P:envMxdizC - If not Underworld/Moon areas branch past.
$00/8757 AD 02 17 LDA $1702 [$00:1702] A:0001 X:0180 Y:0000 P:envMxdizC - Load Map Index Byte 2.
$00/875A C9 5A CMP #$5A A:005A X:0180 Y:0000 P:envMxdizC - Is it Bahamut's Cave or higher?
$00/875C 90 07 BCC $07 [$8765] A:005A X:0180 Y:0000 P:envMxdiZC - If not, branch past.
$00/875E C9 5D CMP #$5D A:005A X:0180 Y:0000 P:envMxdiZC - Is it Glitch World or Higher?
$00/8760 B0 03 BCS $03 [$8765] A:005A X:0180 Y:0000 P:eNvMxdizc - If so, branch past.
$00/8762 4C 6D 87 JMP $876D [$00:876D] A:005A X:0180 Y:0000 P:eNvMxdizc - Jump to Rest of Routine
----------------------------------------------------------
$00/8765 C9 67 CMP #$67 A:005A X:0180 Y:0000 P:eNvMxdizc - Is it Lunar Subterrane 1F or Higher?
$00/8767 90 0C BCC $0C [$8775] A:005A X:0180 Y:0000 P:eNvMxdizc - If not, branch past.
$00/8769 C9 7F CMP #$7F A:005A X:0180 Y:0000 P:eNvMxdizc - Is it (Final Map) Glitch World or less? (Not sure how necessary that is)
$00/876B B0 08 BCS $08 [$8775] A:005A X:0180 Y:0000 P:eNvMxdizc - If not, branch past.
--------------------------------------------------------------------------------------------------------------------------------
$00/876D AD 01 18 LDA $1801 [$00:1801] A:005A X:0180 Y:0000 P:eNvMxdizc - Load A from second byte of encounter data.
$00/8770 09 80 ORA #$80 A:0001 X:0180 Y:0000 P:envMxdizc - Add 80 if applicable.
$00/8772 8D 01 18 STA $1801 [$00:1801] A:0081 X:0180 Y:0000 P:eNvMxdizc - Store A in second byte of encounter data.
I appear to have been mistaken about the Treasure Chest Monster in the Lunar Lobby, that is actually a Red Giant as memory serves right, a Moon Monster who petrifies himself because of using default AI Routines.
What this also tells us is the game looks at encounters in the 0X80 range of encounters to activate the Moon AI.
I hope that was somewhat helpful.