Pulley system. Why do I need to put a minus sign?
Yes, you need to know it in advance. Here's how you do so: In the first equation you wrote, $a$ is positive if the object moves higher on the slope. If this object moves higher up on the slope, the object hanging on the rope would go downwards. That means that a positive $a$ and by extension, a positive force would point downwards. So your equation should not be $T-m_2g=m_2a$ but $m_2g-T=m_2a$.
$T$ has a positive direction in both reference frames
This is incorrect. $T$ is a scalar property of the rope and has no direction. The attachment of the rope to the masses provides a force on the mass, and this does have a direction.
The magnitude of $T$ and the applied force are the same, but the direction of the applied force needs to be accounted for in your reference.
So a single $T$ turns into separate forces on the two masses, and these forces are in different directions along the path of travel, so they should have different signs.
Better to write $$T - m_1g\sin\theta = m_1a_1$$ $$T - m_2g = m_2a_2$$ $$ a_1 = -a_2$$
The acceleration variables represent the acceleration of each mass in its own independent coordinate system, so they should be identified as such. The third equation is an equation of constraint that establishes the connection between the two coordinate systems. By choosing one variable to represent the acceleration of both, you miss that connection.
Keep the coordinate systems separate, and identify constraints explicitly. The simpler problems do yield easily to the approach of choosing a particular set of axes chosen to make the motion appear simple. But complicated problems with several objects connected in complicated ways you will go crazy trying to figure out the "simple" arrangement of axes that simplifies the motion while at the same time respecting the constraints. Each object gets a coordinate system; systems are related by equations of constraint. This is a systematic approach that will pay dividends in the long run. It's a good habit to establish, in my opinion.