Unless you have a good reason for naming a constraint on a temporary table, I would not name them. If you execute a statement like
CREATE TABLE #T(i INT, PRIMARY KEY (i));
then while your connection can reference the table as #T, in tempdb, the table name will be something like #T_______00001B and the primary key name will be something like PK__#T_____4A56BC.
If another connection then runs the same statement, that connection also gets a table it can reference as #T, but in tempdb, the table and constraint will have different names (the hex numbers at the end of the names will be different). As you know, that way each connection has it's own copy of #T and it's own primary key constraint.
But if you do
CREATE TABLE #T(i INT, CONSTRAINT T_PK PRIMARY KEY (i));
Then the primary key created in tempdb will be named T_PK. SQL will not add any characters to make the name unique. So if two connections try to have that table and primary key at the same time, SQL will try to create two objects named T_PK and you will get an error since all object names in a database (tempdb in this case) must be unique.
You said you got the error message "Could not create constraint or index. See previous errors.". There really were two error messages (although depending on how your error handler handles multiple error messages, the first one might not be displayed. The first message would have been "There is already an object named 'T_PK' in the database. (Of course, T_PK would be replaced by whatever name you gave your primary key constraint.
The only way you can name the constraint is either 1) only allow one connection at a time to create and use that tempdb, or 2) make sure that each connection uses a different name for the constraint. But I would recommend just not giving the constraint a name.
Tom