You can create one portfolio per demat account. Suppose, you have three demat accounts, A, B and C. Create three portfolios one for each demat account. Enter transactions of each demat in respective portfolio. This way, you will get capital gains separately for each demat account.
To view the consolidated portfolios across all the demat accounts, you can create a group and link all the portfolios to this group. Also, if you are using Accounting in MProfit, you need to link all three portfolios A, B and C to one Account only.