I tried a few things. One thing I tried was to change the state of
dlga_member_chat:member_talk 4095 13 4 2200 1 144115188075855885 1507 1 144115188075855885 520 3 1224979098644774912 144115188075855885 130 2320 2 5 1224979098644774912 Yes,_{s5}? 71 0
from member_chat to start to see if it would show up then, but that didn't seem to do anything. Looking at the code for it, what it's doing is first storing them, then checking that stored number to see if they are a hero, then it gets the honorific that they use to talk to you (set elsewhere for each companion), then it sets that honorific to display where {s5} is.
And while I'm describing this to you, I suddenly realised what I'm doing wrong. D'oh! Even though conversation.txt stores member_chat there, the actual dialog state is stored in the number - the red 13 in this case. The red 71 is the next dialog that one leads to, which is member_talk if you look it up in dialog_states. Changing the 13 to 0 (start) made it display in the castle, but then it no longer displays in troops - and even displays when you first meet them in the tavern. The change would obviously have to be way more complex to get it to work properly, but you *CAN* get them to talk correctly. You'd just have to add a new dialog entry with conditions that only allow them to talk to you during the castle scene, using start (0) as the dialog state. The trick would be making it specifically affect them only in the castle scene, and only affect the specific heroes.
You could do the castle scene with a check to see if they are in court, which is:
31 2 144115188075856039 1
31 is the function to check if the first equals the second, 144115188075856039 is the $talk context - which I believe is set automatically by the engine, and 1 is talk context court. So if the talk context is court (if they're in a lord's hall or castle) it will come back as true and let the dialog continue.
The check to make sure that they're a companion would be
33 3 144115188075855885 360287970189639844 360287970189639860
33 being a check if the first thing is between the other two things. 144115188075855885 is $g_talk_troop and the other two big numbers are the range of npc heroes.