You problem is you're trying to do a complex conditional within the tag parameters, that's not possible.
Here's a good article regarding parsing conditionals within tags:
http://johndwells.com/blog/expressionengine-parse-order-advanced-conditionals-as-tag-parameters
As you state, the problem is simple conditionals versus complex conditionals.
The problem with your second code:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{exp:low_search:results
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{if:else}
{exp:low_search:results
query="{segment_2}"
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{/if}
...Is that you won't be able to have the opening tag in a separate conditional to the closing tag - EE parses conditionals at a separate stage to tags. It's not linear (working from top to bottom).
This may work:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{exp:low_search:results
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
{if:else}
{exp:low_search:results
query="{segment_2}"
{if segment_1 == "foo"}group_id="6"{/if}
{if segment_1 == "bar"}group_id="7"{/if}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
{/if}
...Where each tag pair is contained within the same conditional.
There's an additional problem in your revised conditional that is showing a parse error:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
If there is no keyword, that tag will return an empty string, resulting in your conditional looking like this prior to EE parsing it: {if {segment_2} == '' OR }
...Which will result in the parse error. This is safer:
{if {segment_2} == '' OR '{exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}'}
With the quotes, it can be parsed correctly as {if {segment_2} == '' OR ''}
Or how I'd approach it, by including in an embed and doing all the conditionals in the parent:
{if {segment_2} == '' OR {exp:segment_search keyword="/^P\d+$/" segments="2" regex="yes"}}
{embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query=""}
{if:else}
{embed=template-group/search-results group_id="{if segment_1 == "foo"}6{/if}{if segment_1 == "bar"}7{/if}" query='query="{segment_2}"'}
{/if}
And in the embed template:
{exp:low_search:results
group_id="{embed:group_id}"
{embed:query}
limit="4"
paginate="bottom"}
{title}
{/exp:low_search:results}
Note: for the first embed, query will be an empty string which is fine to pass as a parameter.