How to output signal when a button is pressed the 2nd time?

A great way to make a button system as you've said is to use a scoreboard objective.

First of all, make the scoreboard objective

Run this command in chat to create a dummy scoreboard objective named Output:

/scoreboard objectives add Output dummy

Next, determine the input source

To do this, place a standard impulse command block after your output and write this into it:

scoreboard players add @a Output 1

After that, set up the output system

Next place multiple always active repeating command blocks next to each other in a row, the length being how many different outputs you want (in this case 2). However, this will only work in single-player. If you want a multiplayer system, separate the repeating command blocks

(It does not matter where in the world you place these repeating command blocks, but putting them near your input will make it simpler to understand what it's doing.)

In the first command block, write this command:

testfor @a[score_Output=1,score_Output_min=1]

In the second, write this:

testfor @a[score_Output=2,score_Output_min=2]

(If you would like more, add more in the row and change the testfor score in ascending order)

Place comparators facing out of these repeating command blocks.

Finally, determine the output type

If you want this system to output to commands, simply place a solid block after the comparators and then your impulse command block after that block. If you want other commands to run as well, you will need to create a chain of always active chain command blocks after the impulse block.

If you want a redstone output, place redstone dust after the comparators and redstone repeaters facing out of those (changing the direction of one if required).

3-way output system